<!-- 逆变器列表 -->
<template>
  <div v-if="powerStation">
    <div class="content">
      <div class="T-title flexBetween">
        <div class="title-l">
          <div :class="{ 'title-l-s': true, active: tabIndex == -1 }" @click="tabClick(-1, '')">
            {{ $t('licence.sys_all') }}
          </div>
          <template v-if="showByType">
            <div v-for="(item, index) in GatewayList" :key="index" class="title-l-s"
              :class="{ 'title-l-s': true, active: tabIndex == index }" @click="tabClick(index, item)"
              @dblclick="gatewayShow(item)">
              {{ item.gatewayName }}
              <!-- 网关hover的样式 -->
              <div class="hover-wangguan">
                <div class="uptriangle"></div>
                <div style="white-space: nowrap">
                  <p>{{ $t('licence.sys_lable') }}{{ item.lable }}</p>
                  <p>{{ $t('licence.versionNo') }}：{{ item.version }}</p>
                  <p>{{ $t('licence.dia_psNum') }}{{ item.psNum }}</p>
                  <p>{{ $t('licence.homElectricity') }}：{{ item.electricity }}</p>
                  <p>{{ $t('licence.sys_dataTime') }}：{{ item.dataTime }}</p>
                </div>
              </div>
            </div>
          </template>
        </div>
        <!-- 立即刷新 -->
        <el-button @click="refreshAll">{{
          $t('licence.sys_refreshAll')
        }}</el-button>

        <el-button v-hasPermi="['monitor:sys:selectAll']" @click="checkedAll">{{
          isAllSelect ? $t('licence.sys_selectAll') : $t('licence.sys_deselectAll')
        }}</el-button>
      </div>
      <!-- 这里查询 -->
      <div v-if="selectNum == 0">
        <el-select clearable @change="selectChanged" v-model="powerState" :placeholder="$t('licence.status')">
          <el-option v-for="item in  options" :key="item.key" :label="$t('licence.type' + item.key)" :value="item.key">
          </el-option>
        </el-select>
        <el-input v-model="serialNumber" :placeholder="$t('licence.sys_serialNumber')" class="inputk"></el-input>
        <el-button @click="getInverterList" type="primary" style="margin: 20px 0">{{ $t('licence.fau_Thequery')
        }}</el-button>
      </div>
      <div v-else style="margin: 20px 0">
        <span>{{ $t('licence.sys_Select') }}<i class="i">{{ selectNum }}</i>{{ $t('licence.sys_term') }}</span>
        <!-- 恢复出厂设置弹框 待机时间 -->
        <el-button class="buttonall" v-hasPermi="['monitor:sys:reset']"
          @click="dialogClick0($t('licence.sys_restoreFactory'))">{{ $t('licence.sys_restoreFactory')
          }}</el-button>
        <el-dialog v-model="dialogShow0" width="30%">
          <div class="titleShow">
            <div class="titles">{{ showInDialogTitle }}</div>
          </div>
          <el-form :inline="true" :model="formInline" :rules="rules" ref="formInlines" class="demo-form-inline">
            <el-form-item :label="$t('licence.sys_guojia')" prop="num_0">
              <el-input style="width: 300px" v-model="formInline.num_0"></el-input>
            </el-form-item>
          </el-form>
          <template #footer>
            <span class="dialog-footer">
              <el-button @click="dialogShow0 = false">{{ $t('licence.cancel') }}</el-button>
              <el-button type="primary" @click="instruction(0)">{{ $t('licence.determine') }}</el-button>
            </span>
          </template>
        </el-dialog>
        <!-- 指令下发弹框 -->
        <el-button class="buttonall" v-hasPermi="['monitor:sys:power']"
          @click="dialogClick2($t('licence.sys_switch'))">{{ $t('licence.sys_switch') }}</el-button>
        <!-- 指令下发弹框 开关机控制 -->
        <el-dialog v-model="dialogShow2" width="30%">
          <div class="titleShow">
            <div class="titles">{{ showInDialogTitle }}</div>
          </div>
          <el-radio style="display: block; margin-bottom: 20px" v-model="open" label="1">
            {{ $t('licence.sys_kai') }}</el-radio>
          <el-radio style="display: block; margin-bottom: 20px" v-model="open" label="2">
            {{ $t('licence.sys_guan') }}</el-radio>
          <template #footer>
            <span class="dialog-footer">
              <el-button @click="dialogShow2 = false">{{ $t('licence.cancel') }}</el-button>
              <el-button type="primary" @click="instruction(2)">{{ $t('licence.determine') }}</el-button>
            </span>
          </template>
        </el-dialog>
        <!-- 指令下发弹框 -->
        <el-button class="buttonall" v-hasPermi="['monitor:sys:command']"
          @click="dialogClick5($t('licence.sys_commandActive'))">{{ $t('licence.sys_commandActive') }}</el-button>
        <!-- 指令下发弹框 指令有功调节 -->
        <el-dialog v-model="dialogShow5" width="30%">
          <div class="titleShow">
            <div class="titles">{{ showInDialogTitle }}</div>
          </div>
          <el-radio style="display: block; margin-bottom: 20px" v-model="switchO" label="1">{{
            $t('licence.sys_kaiqi') }}</el-radio>
          <el-radio style="display: block; margin-bottom: 20px" v-model="switchO" label="2">{{
            $t('licence.sys_guanbi') }}</el-radio>
          <el-form :inline="true" :model="formInline" :rules="rules" ref="formInlines" class="demo-form-inline"
            v-show="switchO == 1">
            <el-form-item :label="$t('licence.sys_zhiling')" prop="num_3">
              <el-input style="width: 300px" v-model="formInline.num_3"
                :placeholder="$t('licence.sys_shuzhi0')"></el-input>
            </el-form-item>
          </el-form>
          <template #footer>
            <span class="dialog-footer">
              <el-button @click="dialogShow5 = false">{{ $t('licence.cancel') }}</el-button>
              <el-button type="primary" @click="instruction(5)">{{ $t('licence.determine') }}</el-button>
            </span>
          </template>
        </el-dialog>
        <!-- 指令下发弹框 -->
        <el-button class="buttonall" v-hasPermi="['monitor:sys:factor']"
          @click="dialogClick7($t('licence.sys_powerFactor'))">{{ $t('licence.sys_powerFactor') }}</el-button>
        <!-- 指令下发弹框 功率因数调节 -->
        <el-dialog v-model="dialogShow7" width="30%">
          <div class="titleShow">
            <div class="titles">{{ showInDialogTitle }}</div>
          </div>
          <el-radio style="display: block; margin-bottom: 20px" v-model="switchS" label="1">{{
            $t('licence.sys_kaiqi') }}</el-radio>
          <el-radio style="display: block; margin-bottom: 20px" v-model="switchS" label="2">{{
            $t('licence.sys_guanbi') }}</el-radio>
          <el-form :inline="true" :model="formInline" :rules="rules" ref="formInlines" class="demo-form-inline"
            v-show="switchS == 1">
            <el-form-item :label="$t('licence.sys_gonglv')" prop="num_5">
              <el-input v-model="formInline.num_5" :placeholder="$t('licence.sys_gonglvshuzhi')"
                style="width: 350px"></el-input>
            </el-form-item>
          </el-form>
          <template #footer>
            <span class="dialog-footer">
              <el-button @click="dialogShow7 = false">{{ $t('licence.cancel') }}</el-button>
              <el-button type="primary" @click="instruction(7)">{{ $t('licence.determine') }}</el-button>
            </span>
          </template>
        </el-dialog>
        <el-button class="buttonall" v-hasPermi="['monitor:sys:protection']"
          @click="dialogClick8($t('licence.sys_protect'))">{{ $t('licence.sys_protect') }}</el-button>
        <!-- 指令下发弹框 保护设置 -->
        <el-dialog v-model="dialogShow8" width="60%">
          <div class="titleShow">
            <div class="titles">{{ showInDialogTitle }}</div>
          </div>
          <div class="conten-main-t flexBetween">
            <div class="l">
              <span class="addstyle">{{ $t('licence.para_guojia') }}</span>
              <el-select v-model="countryCode" clearable @change="countryChanged"
                :placeholder="$t('licence.para_xuanze')">
                <el-option v-for="item  in  optionsCountry" :key="item.machineCode"
                  :label="lang == 0 ? item.country : item.countryEn" :value="item.machineCode">
                </el-option>
              </el-select>
            </div>
            <div class="r">
              <span class="dialog-footer">
                <el-button @click="dialogShow8 = false">{{ $t('licence.cancel') }}</el-button>
                <el-button type="primary"
                  @click="dialogClick8Check($t('licence.sys_set_verify'))">{{ $t('licence.determine') }}</el-button>
                <el-button type="info" @click="getProtectParamByFirmware()">{{ $t('licence.loading') }}</el-button>
              </span>
            </div>
          </div>

          <div class="conten-main-b">
            <ul class="head">
              <li>{{ $t('licence.fau_num') }}</li>
              <li>{{ $t('licence.par_name') }}</li>
              <li>{{ $t('licence.par_resolvingPower') }}</li>
              <li>{{ $t('licence.par_protect') }}</li>
            </ul>
            <ul>
              <li>1</li>
              <li>{{ $t('licence.num1') }}</li>
              <li>1</li>
              <li>
                <el-input v-model="parameterData.protectEnable" :placeholder="parameterData.protectEnable"
                  class="inputW"></el-input>
              </li>
            </ul>
            <ul>
              <li>2</li>
              <li>{{ $t('licence.num2') }}</li>
              <li>0.1</li>
              <li>
                <el-input v-model="parameterData.protectOneSection" :placeholder="parameterData.protectOneSection"
                  class="inputW"></el-input>
              </li>
            </ul>
            <ul>
              <li>3</li>
              <li>{{ $t('licence.num3') }}</li>
              <li>0.1</li>
              <li>
                <el-input v-model="parameterData.protectOneSectionTime"
                  :placeholder="parameterData.protectOneSectionTime" class="inputW"></el-input>
              </li>
            </ul>
            <ul>
              <li>4</li>
              <li>{{ $t('licence.num4') }}</li>
              <li>0.1</li>
              <li>
                <el-input v-model="parameterData.protectTwoSection" :placeholder="parameterData.protectTwoSection"
                  class="inputW"></el-input>
              </li>
            </ul>
            <ul>
              <li>5</li>
              <li>{{ $t('licence.num5') }}</li>
              <li>20</li>
              <li>
                <el-input v-model="parameterData.protectTwoSectionTime"
                  :placeholder="parameterData.protectTwoSectionTime" class="inputW"></el-input>
              </li>
            </ul>
            <ul>
              <li>6</li>
              <li>{{ $t('licence.num6') }}</li>
              <li>0.1</li>
              <li>
                <el-input v-model="parameterData.recoveryValue" :placeholder="parameterData.recoveryValue"
                  class="inputW"></el-input>
              </li>
            </ul>
            <ul>
              <li>7</li>
              <li>{{ $t('licence.num7') }}</li>
              <li>0.1</li>
              <li>
                <el-input v-model="parameterData.overvoltage" :placeholder="parameterData.overvoltage"
                  class="inputW"></el-input>
              </li>
            </ul>
            <ul>
              <li>8</li>
              <li>{{ $t('licence.num8') }}</li>
              <li>0.01</li>
              <li>
                <el-input v-model="parameterData.overcurrentThreshold" :placeholder="parameterData.overcurrentThreshold"
                  class="inputW"></el-input>
              </li>
            </ul>
            <ul>
              <li>9</li>
              <li>{{ $t('licence.num9') }}</li>
              <li>0.01</li>
              <li>
                <el-input v-model="parameterData.instantThreshold" :placeholder="parameterData.instantThreshold"
                  class="inputW"></el-input>
              </li>
            </ul>
            <ul>
              <li>10</li>
              <li>{{ $t('licence.num10') }}</li>
              <li>0.1</li>
              <li>
                <el-input v-model="parameterData.componentThreshold" :placeholder="parameterData.componentThreshold"
                  class="inputW"></el-input>
              </li>
            </ul>
            <ul>
              <li>11</li>
              <li>{{ $t('licence.num11') }}</li>
              <li>0.1</li>
              <li>
                <el-input v-model="parameterData.oLThreshold" :placeholder="parameterData.oLThreshold"
                  class="inputW"></el-input>
              </li>
            </ul>
            <ul>
              <li>12</li>
              <li>{{ $t('licence.num12') }}</li>
              <li>0.1</li>
              <li>
                <el-input v-model="parameterData.vDThreshold" :placeholder="parameterData.vDThreshold"
                  class="inputW"></el-input>
              </li>
            </ul>
            <ul>
              <li>13</li>
              <li>{{ $t('licence.num13') }}</li>
              <li>0.1</li>
              <li>
                <el-input v-model="parameterData.uvOneSection" :placeholder="parameterData.uvOneSection"
                  class="inputW"></el-input>
              </li>
            </ul>
            <ul>
              <li>14</li>
              <li>{{ $t('licence.num14') }}</li>
              <li>20</li>
              <li>
                <el-input v-model="parameterData.uvOneSectionTime" :placeholder="parameterData.uvOneSectionTime"
                  class="inputW"></el-input>
              </li>
            </ul>
            <ul>
              <li>15</li>
              <li>{{ $t('licence.num15') }}</li>
              <li>0.1</li>
              <li>
                <el-input v-model="parameterData.uvTwoSection" :placeholder="parameterData.uvTwoSection"
                  class="inputW"></el-input>
              </li>
            </ul>
            <ul>
              <li>16</li>
              <li>{{ $t('licence.num16') }}</li>
              <li>20</li>
              <li>
                <el-input v-model="parameterData.uvTwoSectionTime" :placeholder="parameterData.uvTwoSectionTime"
                  class="inputW"></el-input>
              </li>
            </ul>
            <ul>
              <li>17</li>
              <li>{{ $t('licence.num17') }}</li>
              <li>0.1</li>
              <li>
                <el-input v-model="parameterData.uvValue" :placeholder="parameterData.uvValue" class="inputW"></el-input>
              </li>
            </ul>
            <ul>
              <li>18</li>
              <li>{{ $t('licence.num18') }}</li>
              <li>0.01</li>
              <li>
                <el-input v-model="parameterData.boostThreshold" :placeholder="parameterData.boostThreshold"
                  class="inputW"></el-input>
              </li>
            </ul>
            <ul>
              <li>19</li>
              <li>{{ $t('licence.num19') }}</li>
              <li>0.01</li>
              <li>
                <el-input v-model="parameterData.invthreshold" :placeholder="parameterData.invthreshold"
                  class="inputW"></el-input>
              </li>
            </ul>
            <ul>
              <li>20</li>
              <li>{{ $t('licence.num20') }}</li>
              <li>0.1</li>
              <li>
                <el-input v-model="parameterData.pvthreshold" :placeholder="parameterData.pvthreshold"
                  class="inputW"></el-input>
              </li>
            </ul>
            <ul>
              <li>21</li>
              <li>{{ $t('licence.num21') }}</li>
              <li>0.1</li>
              <li>
                <el-input v-model="parameterData.pvstopThreshold" :placeholder="parameterData.pvstopThreshold"
                  class="inputW"></el-input>
              </li>
            </ul>
            <ul>
              <li>22</li>
              <li>{{ $t('licence.num22') }}</li>
              <li>0.1</li>
              <li>
                <el-input v-model="parameterData.pvhightThreshold" :placeholder="parameterData.pvhightThreshold"
                  class="inputW"></el-input>
              </li>
            </ul>
            <ul>
              <li>23</li>
              <li>{{ $t('licence.num23') }}</li>
              <li>0.01</li>
              <li>
                <el-input v-model="parameterData.pvothreshold" :placeholder="parameterData.pvothreshold"
                  class="inputW"></el-input>
              </li>
            </ul>
            <ul>
              <li>24</li>
              <li>{{ $t('licence.num24') }}</li>
              <li>0.01</li>
              <li>
                <el-input v-model="parameterData.pqOneSection" :placeholder="parameterData.pqOneSection"
                  class="inputW"></el-input>
              </li>
            </ul>
            <ul>
              <li>25</li>
              <li>{{ $t('licence.num25') }}</li>
              <li>20</li>
              <li>
                <el-input v-model="parameterData.pqOneSectionTime" :placeholder="parameterData.pqOneSectionTime"
                  class="inputW"></el-input>
              </li>
            </ul>
            <ul>
              <li>26</li>
              <li>{{ $t('licence.num26') }}</li>
              <li>0.01</li>
              <li>
                <el-input v-model="parameterData.pqRecoveryValue" :placeholder="parameterData.pqRecoveryValue"
                  class="inputW"></el-input>
              </li>
            </ul>
            <ul>
              <li>27</li>
              <li>{{ $t('licence.num27') }}</li>
              <li>1</li>
              <li>
                <el-input v-model="parameterData.psVoltageKp" :placeholder="parameterData.psVoltageKp"
                  class="inputW"></el-input>
              </li>
            </ul>
            <ul>
              <li>28</li>
              <li>{{ $t('licence.num28') }}</li>
              <li>1</li>
              <li>
                <el-input v-model="parameterData.psVoltageKi" :placeholder="parameterData.psVoltageKi"
                  class="inputW"></el-input>
              </li>
            </ul>
            <ul>
              <li>29</li>
              <li>{{ $t('licence.num29') }}</li>
              <li>1</li>
              <li>
                <el-input v-model="parameterData.psCurrentKp" :placeholder="parameterData.psCurrentKp"
                  class="inputW"></el-input>
              </li>
            </ul>
            <ul>
              <li>30</li>
              <li>{{ $t('licence.num30') }}</li>
              <li>1</li>
              <li>
                <el-input v-model="parameterData.psCurrentKi" :placeholder="parameterData.psCurrentKi"
                  class="inputW"></el-input>
              </li>
            </ul>
            <ul>
              <li>31</li>
              <li>{{ $t('licence.num31') }}</li>
              <li>1</li>
              <li>
                <el-input v-model="parameterData.boostVoltageKp" :placeholder="parameterData.boostVoltageKp"
                  class="inputW"></el-input>
              </li>
            </ul>
            <ul>
              <li>32</li>
              <li>{{ $t('licence.num32') }}</li>
              <li>1</li>
              <li>
                <el-input v-model="parameterData.boostVoltageKi" :placeholder="parameterData.boostVoltageKi"
                  class="inputW"></el-input>
              </li>
            </ul>
            <ul>
              <li>33</li>
              <li>{{ $t('licence.num33') }}</li>
              <li>1</li>
              <li>
                <el-input v-model="parameterData.boostCurrentKp" :placeholder="parameterData.boostCurrentKp"
                  class="inputW"></el-input>
              </li>
            </ul>
            <ul>
              <li>34</li>
              <li>{{ $t('licence.num34') }}</li>
              <li>1</li>
              <li>
                <el-input v-model="parameterData.boostCurrentKi" :placeholder="parameterData.boostCurrentKi"
                  class="inputW"></el-input>
              </li>
            </ul>
            <ul>
              <li>35</li>
              <li>{{ $t('licence.num35') }}</li>
              <li>0.01</li>
              <li>
                <el-input v-model="parameterData.uqOneSection" :placeholder="parameterData.uqOneSection"
                  class="inputW"></el-input>
              </li>
            </ul>
            <ul>
              <li>36</li>
              <li>{{ $t('licence.num36') }}</li>
              <li>20</li>
              <li>
                <el-input v-model="parameterData.uqOneSectionTime" :placeholder="parameterData.uqOneSectionTime"
                  class="inputW"></el-input>
              </li>
            </ul>
            <ul>
              <li>37</li>
              <li>{{ $t('licence.num37') }}</li>
              <li>0.01</li>
              <li>
                <el-input v-model="parameterData.uqRecoveryValue" :placeholder="parameterData.uqRecoveryValue"
                  class="inputW"></el-input>
              </li>
            </ul>
            <ul>
              <li>38</li>
              <li>{{ $t('licence.num38') }}</li>
              <li>1</li>
              <li>
                <el-input v-model="parameterData.faultOneHight" :placeholder="parameterData.faultOneHight"
                  class="inputW"></el-input>
              </li>
            </ul>
            <ul>
              <li>39</li>
              <li>{{ $t('licence.num39') }}</li>
              <li>1</li>
              <li>
                <el-input v-model="parameterData.faultOneLow" :placeholder="parameterData.faultOneLow"
                  class="inputW"></el-input>
              </li>
            </ul>
            <ul>
              <li>40</li>
              <li>{{ $t('licence.num40') }}</li>
              <li>1</li>
              <li>
                <el-input v-model="parameterData.faulTwoHight" :placeholder="parameterData.faulTwoHight"
                  class="inputW"></el-input>
              </li>
            </ul>
            <ul>
              <li>41</li>
              <li>{{ $t('licence.num41') }}</li>
              <li>1</li>
              <li>
                <el-input v-model="parameterData.faultTwoLow" :placeholder="parameterData.faultTwoLow"
                  class="inputW"></el-input>
              </li>
            </ul>
            <ul>
              <li>42</li>
              <li>{{ $t('licence.num42') }}</li>
              <li>1</li>
              <li>
                <el-input v-model="parameterData.faultThreeHight" :placeholder="parameterData.faultThreeHight"
                  class="inputW"></el-input>
              </li>
            </ul>
            <ul>
              <li>43</li>
              <li>{{ $t('licence.num43') }}</li>
              <li>1</li>
              <li>
                <el-input v-model="parameterData.faultThreeLow" :placeholder="parameterData.faultThreeLow"
                  class="inputW"></el-input>
              </li>
            </ul>
            <ul>
              <li>44</li>
              <li>{{ $t('licence.num44') }}</li>
              <li>1</li>
              <li>
                <el-input v-model="parameterData.reserveOne" :placeholder="parameterData.reserveOne"
                  class="inputW"></el-input>
              </li>
            </ul>
            <ul>
              <li>45</li>
              <li>{{ $t('licence.num45') }}</li>
              <li>1</li>
              <li>
                <el-input v-model="parameterData.reserveTwo" :placeholder="parameterData.reserveTwo"
                  class="inputW"></el-input>
              </li>
            </ul>
          </div>
        </el-dialog>

        <el-dialog v-model="dialogShow8Check" width="30%">
          <div class="titleShow">
            <div class="titles">{{ showInDialogSubTitle }}</div>
          </div>
          <el-form :inline="true" :model="formInline" :rules="rules" ref="formInlines" class="demo-form-inline">
            <el-form-item :label="$t('licence.sys_set_password')" prop="num_8_0">
              <el-input style="width: 300px" v-model="formInline.num_8_0"></el-input>
            </el-form-item>
          </el-form>
          <template #footer>
            <span class="dialog-footer">
              <el-button @click="dialogShow8Check = false">{{ $t('licence.cancel') }}</el-button>
              <el-button type="primary" @click="instruction(8)">{{ $t('licence.determine') }}</el-button>
            </span>
          </template>
        </el-dialog>

        <!-- 固件升级 -->
        <el-button class="buttonall" v-hasPermi="['monitor:sys:firmware']"
          @click="dialogClick10($t('licence.sys_upgrade'))">{{ $t('licence.sys_upgrade') }}</el-button>
        <el-dialog v-model="dialogShow10" width="60%">
          <div class="titleShow">
            <div class="titles">{{ showInDialogTitle }}</div>
          </div>
          <el-table ref="singleTable" :data="editionList" highlight-current-row style="width: 100%">
            <el-table-column :label="$t('licence.sys_xuanze')" width="80">
              <template #default="scope">
                <el-radio :label="scope.$index" v-model="editionRadio"
                  @change.native="getCurrentRow(scope.row)"></el-radio>
              </template>
            </el-table-column>
            <el-table-column property="versionNo" :label="$t('licence.versionNo')"></el-table-column>
            <el-table-column property="versionName" :label="$t('licence.versionName')"></el-table-column>
            <el-table-column property="upgradeTip" :label="$t('licence.upgradeTip')"
              :show-overflow-tooltip="true"></el-table-column>
            <el-table-column property="upgradeTime" width="200px" :label="$t('licence.upgradeTime')">
              <template #default="scope">
                {{ format.FormatDate(scope.row.upgradeTime) }}
              </template>
            </el-table-column>
            <el-table-column property="status" :label="$t('licence.sys_status')">
              <template #default="{ row }">
                <el-tag v-if="row.status == 0">{{ $t('licence.sys_normal') }}</el-tag>
                <el-tag type="danger" v-if="row.status == 1">{{
                  $t('licence.sys_tingyong')
                }}</el-tag>
              </template>
            </el-table-column>
            <el-table-column property="type" :label="$t('licence.sys_gujian')">
              <template #default="{ row }">
                <p v-if="row.type == 2">{{ $t('licence.sys_nibianqi') }}</p>
              </template>
            </el-table-column>
            <el-table-column property="remark" :label="$t('licence.remark')"></el-table-column>
          </el-table>
          <!-- 分页 -->
          <div class="block" style="margin: 20px">
            <el-pagination background @size-change="editionSizeChange" @current-change="editionCurrentChange"
              :current-page="editionData.page" :page-size="editionData.pagesize" :page-sizes="[2, 4, 6, 8, 10]"
              layout="prev, pager, next,total, jumper" :total="editionData.total">
            </el-pagination>
          </div>
          <el-form ref="upgradeForm" :model="upgradeForm" :rules="rules" label-width="100px">
            <el-form-item :label="$t('licence.gengxinremark')" prop="remark">
              <el-input v-model="upgradeForm.remark" :placeholder="$t('licence.remark')" />
            </el-form-item>
          </el-form>
          <template #footer>
            <span class="dialog-footer">
              <el-button @click="dialogShow10 = false">{{ $t('licence.cancel') }}</el-button>
              <el-button type="primary" @click="instruction(10)">{{ $t('licence.determine') }}</el-button>
            </span>
          </template>
        </el-dialog>
        <!-- 新加按钮第是一个 固定有功调节 -->
        <el-button class="buttonall" v-hasPermi="['monitor:sys:command']"
          @click="dialogClick11($t('licence.sys_fixed'))">{{ $t('licence.sys_fixed') }}</el-button>
        <!-- 指令下发弹框 指令有功调节 -->
        <el-dialog v-model="dialogShow11" width="30%">
          <div class="titleShow">
            <div class="titles">{{ showInDialogTitle }}</div>
          </div>
          <el-radio style="display: block; margin-bottom: 20px" v-model="switchG" label="1">{{
            $t('licence.sys_kaiqi') }}</el-radio>
          <el-radio style="display: block; margin-bottom: 20px" v-model="switchG" label="2">{{
            $t('licence.sys_guanbi') }}</el-radio>
          <el-form :inline="true" :model="formInline" :rules="rules" ref="formInlines" class="demo-form-inline"
            v-show="switchG == 1">
            <el-form-item :label="$t('licence.sys_zhilingfixed')" prop="num_6">
              <el-input style="width: 300px" v-model="formInline.num_6"
                :placeholder="$t('licence.sys_shuzhi0')"></el-input>
            </el-form-item>
          </el-form>
          <template #footer>
            <span class="dialog-footer">
              <el-button @click="dialogShow11 = false">{{ $t('licence.cancel') }}</el-button>
              <el-button type="primary" @click="instruction(11)">{{ $t('licence.determine') }}</el-button>
            </span>
          </template>
        </el-dialog>

        <!-- 12 安规参数设置 -->
        <el-button class="buttonall" v-hasPermi="['monitor:sys:command']"
          @click="dialogClick12($t('licence.sys_safetyParam'))">{{ $t('licence.sys_safetyParam') }}</el-button>
        <!-- 指令下发弹框 安规参数设置 -->
        <el-dialog v-model="dialogShow12" width="60%">
          <div class="titleShow">
            <div class="titles">{{ showInDialogTitle }}</div>
          </div>
          <template #footer>
            <span class="dialog-footer">
              <el-button @click="dialogShow12 = false">{{ $t('licence.cancel') }}</el-button>
              <el-button type="primary"
                @click="dialogClick12Check($t('licence.sys_set_verify'))">{{ $t('licence.determine') }}</el-button>
            </span>
          </template>
          <span class="safety-right">
            <el-button type="info" @click="getSafetyParamByFirmware()">{{
              $t('licence.loading')
            }}</el-button>
          </span>
          <div class="conten-main-b">
            <ul class="head">
              <li>{{ $t('licence.fau_num') }}</li>
              <li>{{ $t('licence.par_name') }}</li>
              <li>{{ $t('licence.par_resolvingPower') }}</li>
              <li>{{ $t('licence.par_protect') }}</li>
            </ul>
            <ul>
              <li>1</li>
              <li>{{ $t('licence.safety_num1') }}</li>
              <li></li>
              <li>
                <el-input v-model="safetyParameterData.country" :placeholder="safetyParameterData.country"
                  class="inputW"></el-input>
              </li>
            </ul>
            <ul>
              <li>2</li>
              <li>{{ $t('licence.safety_num2') }}</li>
              <li>0.1</li>
              <li>
                <el-input v-model="safetyParameterData.pigMinV" :placeholder="safetyParameterData.pigMinV"
                  class="inputW"></el-input>
              </li>
            </ul>
            <ul>
              <li>3</li>
              <li>{{ $t('licence.safety_num3') }}</li>
              <li>0.1</li>
              <li>
                <el-input v-model="safetyParameterData.pigMaxV" :placeholder="safetyParameterData.pigMaxV"
                  class="inputW"></el-input>
              </li>
            </ul>
            <ul>
              <li>4</li>
              <li>{{ $t('licence.safety_num4') }}</li>
              <li>0.01</li>
              <li>
                <el-input v-model="safetyParameterData.pigMinF" :placeholder="safetyParameterData.pigMinF"
                  class="inputW"></el-input>
              </li>
            </ul>
            <ul>
              <li>5</li>
              <li>{{ $t('licence.safety_num5') }}</li>
              <li>0.01</li>
              <li>
                <el-input v-model="safetyParameterData.pigMaxF" :placeholder="safetyParameterData.pigMaxF"
                  class="inputW"></el-input>
              </li>
            </ul>
            <ul>
              <li>6</li>
              <li>{{ $t('licence.safety_num6') }}</li>
              <li>1</li>
              <li>
                <el-input v-model="safetyParameterData.reconnectWait" :placeholder="safetyParameterData.reconnectWait"
                  class="inputW"></el-input>
              </li>
            </ul>
            <ul>
              <li>7</li>
              <li>{{ $t('licence.safety_num7') }}</li>
              <li>1</li>
              <li>
                <el-input v-model="safetyParameterData.startWait" :placeholder="safetyParameterData.startWait"
                  class="inputW"></el-input>
              </li>
            </ul>
            <ul>
              <li>8</li>
              <li>{{ $t('licence.safety_num8') }}</li>
              <li>0.1</li>
              <li>
                <el-input v-model="safetyParameterData.riseSlope" :placeholder="safetyParameterData.riseSlope"
                  class="inputW"></el-input>
              </li>
            </ul>
            <ul>
              <li>9</li>
              <li>{{ $t('licence.safety_num9') }}</li>
              <li></li>
              <li>
                <el-input v-model="safetyParameterData.puCurveEnable" :placeholder="safetyParameterData.puCurveEnable"
                  class="inputW"></el-input>
              </li>
            </ul>
            <ul>
              <li>10</li>
              <li>{{ $t('licence.safety_num10') }}</li>
              <li>0.1</li>
              <li>
                <el-input v-model="safetyParameterData.puCurveStartV" :placeholder="safetyParameterData.puCurveStartV"
                  class="inputW"></el-input>
              </li>
            </ul>
            <ul>
              <li>11</li>
              <li>{{ $t('licence.safety_num11') }}</li>
              <li>0.1</li>
              <li>
                <el-input v-model="safetyParameterData.puCurveEndV" :placeholder="safetyParameterData.puCurveEndV"
                  class="inputW"></el-input>
              </li>
            </ul>
            <ul>
              <li>12</li>
              <li>{{ $t('licence.safety_num12') }}</li>
              <li>1</li>
              <li>
                <el-input v-model="safetyParameterData.puCurveResTime" :placeholder="safetyParameterData.puCurveResTime"
                  class="inputW"></el-input>
              </li>
            </ul>
            <ul>
              <li>13</li>
              <li>{{ $t('licence.safety_num13') }}</li>
              <li>1</li>
              <li>
                <el-input v-model="safetyParameterData.puCurveResDelay"
                  :placeholder="safetyParameterData.puCurveResDelay" class="inputW"></el-input>
              </li>
            </ul>
            <ul>
              <li>14</li>
              <li>{{ $t('licence.safety_num14') }}</li>
              <li>1</li>
              <li>
                <el-input v-model="safetyParameterData.ofEnable" :placeholder="safetyParameterData.ofEnable"
                  class="inputW"></el-input>
              </li>
            </ul>
            <ul>
              <li>15</li>
              <li>{{ $t('licence.safety_num15') }}</li>
              <li>0.01</li>
              <li>
                <el-input v-model="safetyParameterData.ofPoint" :placeholder="safetyParameterData.ofPoint"
                  class="inputW"></el-input>
              </li>
            </ul>
            <ul>
              <li>16</li>
              <li>{{ $t('licence.safety_num16') }}</li>
              <li>0.1</li>
              <li>
                <el-input v-model="safetyParameterData.ofSlope" :placeholder="safetyParameterData.ofSlope"
                  class="inputW"></el-input>
              </li>
            </ul>
            <ul>
              <li>17</li>
              <li>{{ $t('licence.safety_num17') }}</li>
              <li>1</li>
              <li>
                <el-input v-model="safetyParameterData.ofResDelay" :placeholder="safetyParameterData.ofResDelay"
                  class="inputW"></el-input>
              </li>
            </ul>
            <ul>
              <li>18</li>
              <li>{{ $t('licence.safety_num18') }}</li>
              <li></li>
              <li>
                <el-input v-model="safetyParameterData.reactiveEnable" :placeholder="safetyParameterData.reactiveEnable"
                  class="inputW"></el-input>
              </li>
            </ul>
            <ul>
              <li>19</li>
              <li>{{ $t('licence.safety_num19') }}</li>
              <li>0.1</li>
              <li>
                <el-input v-model="safetyParameterData.quCurveStartUv" :placeholder="safetyParameterData.quCurveStartUv"
                  class="inputW"></el-input>
              </li>
            </ul>
            <ul>
              <li>20</li>
              <li>{{ $t('licence.safety_num20') }}</li>
              <li>0.1</li>
              <li>
                <el-input v-model="safetyParameterData.quCurveEndUv" :placeholder="safetyParameterData.quCurveEndUv"
                  class="inputW"></el-input>
              </li>
            </ul>
            <ul>
              <li>21</li>
              <li>{{ $t('licence.safety_num21') }}</li>
              <li>0.1</li>
              <li>
                <el-input v-model="safetyParameterData.quCurveStartOv" :placeholder="safetyParameterData.quCurveStartOv"
                  class="inputW"></el-input>
              </li>
            </ul>
            <ul>
              <li>22</li>
              <li>{{ $t('licence.safety_num22') }}</li>
              <li>0.1</li>
              <li>
                <el-input v-model="safetyParameterData.quCurveEndOv" :placeholder="safetyParameterData.quCurveEndOv"
                  class="inputW"></el-input>
              </li>
            </ul>
            <ul>
              <li>23</li>
              <li>{{ $t('licence.safety_num23') }}</li>
              <li>1</li>
              <li>
                <el-input v-model="safetyParameterData.quCurveResTime" :placeholder="safetyParameterData.quCurveResTime"
                  class="inputW"></el-input>
              </li>
            </ul>
            <ul>
              <li>24</li>
              <li>{{ $t('licence.safety_num24') }}</li>
              <li>1</li>
              <li>
                <el-input v-model="safetyParameterData.quCurveResDelay" :placeholder="safetyParameterData.quCurveResDelay"
                  class="inputW"></el-input>
              </li>
            </ul>
            <ul>
              <li>25</li>
              <li>{{ $t('licence.safety_num25') }}</li>
              <li></li>
              <li>
                <el-input v-model="safetyParameterData.fixedPowerFactorValue"
                  :placeholder="safetyParameterData.fixedPowerFactorValue" class="inputW"></el-input>
              </li>
            </ul>
            <ul>
              <li>26</li>
              <li>{{ $t('licence.safety_num26') }}</li>
              <li></li>
              <li>
                <el-input v-model="safetyParameterData.reactivePowerRatioValue"
                  :placeholder="safetyParameterData.reactivePowerRatioValue" class="inputW"></el-input>
              </li>
            </ul>
            <ul>
              <li>27</li>
              <li>{{ $t('licence.safety_num27') }}</li>
              <li></li>
              <li>
                <el-input v-model="safetyParameterData.minCos" :placeholder="safetyParameterData.minCos"
                  class="inputW"></el-input>
              </li>
            </ul>
            <ul>
              <li>28</li>
              <li>{{ $t('licence.safety_num28') }}</li>
              <li></li>
              <li>
                <el-input v-model="safetyParameterData.pfCurveStartPercent"
                  :placeholder="safetyParameterData.pfCurveStartPercent" class="inputW"></el-input>
              </li>
            </ul>
            <ul>
              <li>29</li>
              <li>{{ $t('licence.safety_num29') }}</li>
              <li></li>
              <li>
                <el-input v-model="safetyParameterData.pfCurveEndPercent"
                  :placeholder="safetyParameterData.pfCurveEndPercent" class="inputW"></el-input>
              </li>
            </ul>
            <ul>
              <li>30</li>
              <li>{{ $t('licence.safety_num30') }}</li>
              <li></li>
              <li>
                <el-input v-model="safetyParameterData.lcEnable" :placeholder="safetyParameterData.lcEnable"
                  class="inputW"></el-input>
              </li>
            </ul>
            <ul>
              <li>31</li>
              <li>{{ $t('licence.safety_num31') }}</li>
              <li>0.1</li>
              <li>
                <el-input v-model="safetyParameterData.lcCurveVoltageOne"
                  :placeholder="safetyParameterData.lcCurveVoltageOne" class="inputW"></el-input>
              </li>
            </ul>
            <ul>
              <li>32</li>
              <li>{{ $t('licence.safety_num32') }}</li>
              <li>1</li>
              <li>
                <el-input v-model="safetyParameterData.lcCurveVoltageOneTime"
                  :placeholder="safetyParameterData.lcCurveVoltageOneTime" class="inputW"></el-input>
              </li>
            </ul>
            <ul>
              <li>33</li>
              <li>{{ $t('licence.safety_num33') }}</li>
              <li>0.1</li>
              <li>
                <el-input v-model="safetyParameterData.lcCurveVoltageTwo"
                  :placeholder="safetyParameterData.lcCurveVoltageTwo" class="inputW"></el-input>
              </li>
            </ul>
            <ul>
              <li>34</li>
              <li>{{ $t('licence.safety_num34') }}</li>
              <li>1</li>
              <li>
                <el-input v-model="safetyParameterData.lcCurveVoltageTwoTime"
                  :placeholder="safetyParameterData.lcCurveVoltageTwoTime" class="inputW"></el-input>
              </li>
            </ul>
          </div>
        </el-dialog>

        <el-dialog v-model="dialogShow12Check" width="30%">
          <div class="titleShow">
            <div class="titles">{{ showInDialogSubTitle }}</div>
          </div>
          <el-form :inline="true" :model="formInline" :rules="rules" ref="formInlines" class="demo-form-inline">
            <el-form-item :label="$t('licence.sys_set_password')" prop="num_12_0">
              <el-input style="width: 300px" v-model="formInline.num_12_0"></el-input>
            </el-form-item>
          </el-form>
          <template #footer>
            <span class="dialog-footer">
              <el-button @click="dialogShow12Check = false">{{ $t('licence.cancel') }}</el-button>
              <el-button type="primary" @click="instruction(13)">{{ $t('licence.determine') }}</el-button>
            </span>
          </template>
        </el-dialog>
        <!-- 12 自检模式设置 -->
        <el-button class="buttonall" v-hasPermi="['monitor:sys:selfTest']"
          @click="dialogClick13($t('licence.sys_selfTest'))">{{ $t('licence.sys_selfTest') }}</el-button>
        <!-- 自检模式 -->
        <el-dialog v-model="dialogShow13" width="60%">
          <div class="titleShow">
            <div class="titles">{{ showInDialogTitle }}</div>
          </div>
          <el-table :data="selfTestList" border stripe table-layout="fixed" :show-header="false" style="margin-top:20px">
            <el-table-column prop="label"></el-table-column>
            <el-table-column prop="data"></el-table-column>
          </el-table>
          <template #footer>
            <span class="dialog-footer">
              <el-button @click="dialogShow13 = false">{{ $t('licence.sys_startTest') }}</el-button>
              <el-button type="primary"
                @click="dialogClick13Check($t('licence.sys_checkResult'))">{{ $t('licence.sys_checkResult') }}</el-button>
            </span>
          </template>
        </el-dialog>
        <!-- 自检报告 -->
        <el-dialog v-model="dialogShow13Check" width="30%">
          <div class="titleShow">
            <div class="titles">{{ showInDialogSubTitle }}</div>
          </div>
          <el-button type="primary" @click="exportToCSV">{{
            $t('licence.sta_export')
          }}</el-button>
          <el-table :data="testReport" border stripe table-layout="fixed" :show-header="false" style="margin-top:20px">
            <el-table-column prop="label"></el-table-column>
            <el-table-column prop="data"></el-table-column>
            <el-table-column prop="Result"></el-table-column>
          </el-table>
          <template #footer>
            <span class="dialog-footer">
              <el-button type="primary" @click="dialogShow13Check = false">{{ $t('licence.determine') }}</el-button>
            </span>
          </template>
        </el-dialog>
      </div>

      <!-- 根据num动态切换显示div内容 -->
      <div>
        <ul class="main">
          <!-- inverterList这个在哪里获取的 -->
          <li class="main-content" v-for="( item, index ) in  inverterList" :key="index"
            :class="{ actives: item.isSelect }" @click="actives(index, item.id)" @dblclick="EquipmentShow(item)">
            <!-- 逆变器名字 -->
            <div class="titleW flexBetween">
              <p v-if="item.state == 0">
                <el-tag type="success" size="small" style="margin-right: 5px">
                  {{ $t('licence.sys_normal') }}</el-tag>
                {{ item.label }}
              </p>
              <p v-if="item.state == 1">
                <el-tag type="danger" size="small" style="margin-right: 5px">
                  {{ $t('licence.sys_fault') }}</el-tag>
                {{ item.label }}
              </p>
              <p v-if="item.state == 2">
                <el-tag type="info" size="small" style="margin-right: 5px">
                  {{ $t('licence.sys_line') }}</el-tag>
                {{ item.label }}
              </p>
              <p v-if="item.state == 3">
                <el-tag type="warning" size="small" style="margin-right: 5px">
                  {{ $t('licence.sys_alert') }}</el-tag>
                {{ item.label }}
              </p>
              <!-- 这里是勾选 点击切换的都是改着一个值 显示不了多选-->
              <!-- 用的是同一个icon -->
              <!-- 这样每个数据就是单独的-->
              <p class="iconBg" v-if="item.isSelect">
                <el-icon class="iconA" v-show="item.state == 0" style="color: #13ce66">
                  <SuccessFilled />
                </el-icon>
                <el-icon class="iconA" v-show="item.state == 1" style="color: #f56c6c">
                  <SuccessFilled />
                </el-icon>
                <el-icon class="iconA" v-show="item.state == 2" style="color: #909399">
                  <SuccessFilled />
                </el-icon>
                <el-icon class="iconA" v-show="item.state == 3" style="color: #ffba00">
                  <SuccessFilled />
                </el-icon>
              </p>
            </div>
            <!-- 逆变器详细信息 -->
            <div class="tiaoHover">
              <p class="tiao">
                <span class="tiao-l">{{ $t('licence.sys_realtimePower') }}(W)</span>
                <span class="tiao-r">{{ item.realtimePower }}</span>
              </p>
              <p class="tiao">
                <span class="tiao-l">{{ $t('licence.sys_todayEnergy') }}(kWh)</span>
                <span class="tiao-r">{{ item.todayEnergy }}</span>
              </p>
              <p class="tiao">
                <span class="tiao-l">{{ $t('licence.sys_cumulativeEnergy') }}(kWh)</span>
                <span class="tiao-r">{{ item.cumulativeEnergy }}</span>
              </p>
              <p class="tiao">
                <span class="tiao-l">{{ $t('licence.sys_dataTime') }}</span>
                <span class="tiao-r">{{ format.FormatDate(item.dataTime) }}</span>
              </p>
              <p class="tiao">
                <span class="tiao-l">{{ $t('licence.sys_country') }}</span>
                <span class="tiao-r">{{ item.country }}</span>
              </p>
              <p class="tiao" v-if="env == 'staging'">
                <span class="tiao-l">{{ $t('licence.sys_gatbb') }}</span><span class="tiao-r">{{ item.gatVersion }}</span>
              </p>
              <p class="tiao" v-if="env == 'staging'">
                <span class="tiao-l">{{ $t('licence.sys_dspyjbb') }}</span><span class="tiao-r">{{ item.dspmVersion
                }}</span>
              </p>
            </div>
            <!-- 逆变器hover的样式 -->
            <div class="hover-content">
              <div class="uptriangle"></div>
              <p>
                <span>{{ $t('licence.sys_dcCurrent') }}(A)：</span>
                <span>{{ item.dcCurrent }}</span>
              </p>
              <p>
                <span>{{ $t('licence.sys_dcVoltage') }}(V)：</span>
                <span>{{ item.dcVoltage }}</span>
              </p>
              <p>
                <span>{{ $t('licence.sys_acCurrent') }}(A)：</span>
                <span>{{ item.acCurrent }}</span>
              </p>
              <p>
                <span>{{ $t('licence.sys_acVoltage') }}(V)：</span>
                <span>{{ item.acVoltage }}</span>
              </p>
              <p>
                <span>{{ $t('licence.sys_temperature') }}(&#176;C)：</span>
                <span>{{ item.temperature }}</span>
              </p>
              <p>
                <span>{{ $t('licence.sys_ratedPower') }}(W)：</span>
                <span>{{ item.ratedPower }}</span>
              </p>
              <p>
                <span>{{ $t('licence.sys_createTime') }}：</span>
                <span>{{ format.FormatDate(item.createTime) }}</span>
              </p>
              <p v-if="!showByType">
                <span>{{ $t('licence.versionNo') }}：</span>
                <span>{{ item.gatVersion }}</span>
              </p>
            </div>
          </li>
        </ul>
      </div>
    </div>
    <!-- 网关信息弹框 -->
    <!-- 设备信息弹框 -->
    <el-dialog v-model="gatewayDialog" width="70%">
      <div>
        <!-- 弹框的tab切换 -->
        <div class="titleShow">
          <div class="titles" :class="gatewaynum == 1 ? 'active' : ''" @click="gatewayTabShow(1)">
            {{ $t('licence.sys_historicalFault') }}
          </div>
          <div class="titles" :class="gatewaynum == 2 ? 'active' : ''" @click="gatewayTabShow(2)">
            {{ $t('licence.sys_gateway') }}
          </div>
        </div>
        <!-- 历史故障 -->
        <div v-if="gatewaynum == 1">
          <el-table :data="gatewayFaultData" stripe class="tableStyle">
            <el-table-column prop="num" :label="$t('licence.fau_num')" width="100">
            </el-table-column>

            <el-table-column prop="code" :label="$t('licence.fau_faultId')" width="120">
            </el-table-column>
            <el-table-column prop="faultDesc" :label="$t('licence.fau_faultDesc')">
            </el-table-column>
            <el-table-column :label="$t('licence.fau_createTime')" width="220">
              <template #default="scope">
                {{ format.FormatDate(scope.row.createTime) }}
              </template>
            </el-table-column>
            <el-table-column :label="$t('licence.fau_updateTime')" width="220">
              <template #default="scope">
                {{ format.FormatDate(scope.row.updateTime) }}
              </template>
            </el-table-column>
            <el-table-column prop="realSolution" :label="$t('licence.fau_realSolution')" width="240">
            </el-table-column>
            <el-table-column :label="$t('licence.fau_operation')" width="160">
              <template #default="scope">
                <el-button v-if="scope.row.state === 1" @click="Tosolve(scope.row)" type="text" size="small"
                  style="color: #305add">{{ $t('licence.sys_weijiejue') }}</el-button>
                <p v-if="scope.row.state === 0">{{ $t('licence.sys_yijiejue') }}</p>
              </template>
            </el-table-column>
          </el-table>
          <!-- 分页区 -->
          <div class="block" style="margin: 20px">
            <el-pagination background @size-change="handleSizeChangeGateway" @current-change="handleCurrentChangeGateway"
              :current-page="queryDataGateway.page" :page-size="queryDataGateway.pagesize" :page-sizes="[2, 4, 6, 8, 10]"
              layout="sizes, prev, pager, next,total, jumper" :total="queryDataGateway.total">
            </el-pagination>
          </div>
        </div>

        <!-- 曲线图 -->
        <div v-if="gatewaynum == 2">
          <div>
            <div class="title" id="title">
              <!-- 年月日选择 -->
              <div class="time-box flexStart">
                <el-radio-group style="margin-right: 20px" v-model="radioGateway" fill="#305ADD" border="true"
                  @change="getChartsGateway">
                  <el-radio-button :label="1">{{ $t('licence.sta_day') }}</el-radio-button>
                  <el-radio-button :label="2">{{ $t('licence.sta_week') }}</el-radio-button>
                  <el-radio-button :label="3">{{ $t('licence.sta_month') }}</el-radio-button>
                  <el-radio-button :label="4">{{ $t('licence.sta_quarter') }}</el-radio-button>
                  <el-radio-button :label="5">{{ $t('licence.sta_year') }}</el-radio-button>
                  <el-radio-button :label="6">{{ $t('licence.sta_liyear') }}</el-radio-button>
                  <el-radio-button :label="7">{{ $t('licence.sta_calendarQuarter') }}</el-radio-button>
                </el-radio-group>
                <el-date-picker style="margin: 0 20px; width: 180px" :clearable="true" format="YYYY/MM/DD"
                  value-format="YYYY-MM-DD" v-model="searchDay.stockDate" @change="changeTime" type="date"
                  :placeholder="$t('licence.sta_selectDate')">
                </el-date-picker>
                <el-button @click="getChartsGateway" type="primary" style="margin: 20px 0">{{
                  $t('licence.fau_Thequery') }}</el-button>
              </div>
            </div>
            <!-- 数据曲线图 -->
            <!--日则线图 -->
            <div v-show="radioGateway <= 1">
              <!-- 发电趋势 -->
              <div class="title" id="title">
                <h3 class="big-title">{{ $t('licence.fau_Trendcurve') }}</h3>
                <div id="TrendcurveGateway" ref="cqjk" class="curveData"></div>
              </div>
            </div>
            <!-- 日以外柱状图 -->
            <div v-show="radioGateway > 1">
              <div class="title" id="title">
                <h3 class="big-title">{{ $t('licence.fau_Trendcurve') }}</h3>
                <div id="ElectricityGateway" class="curveData"></div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </el-dialog>
    <!-- 逆变器设备信息弹框 -->
    <el-dialog v-model="showDialog" width="70%">
      <div>
        <!-- 弹框的tab切换 -->
        <div class="titleShow">
          <div class="titles" :class="num == 1 ? 'active' : ''" @click="tabShow(1)">
            {{ $t('licence.sys_equipmentInformation') }}
          </div>
          <div class="titles" :class="num == 2 ? 'active' : ''" @click="tabShow(2)">
            {{ $t('licence.sys_historicalFault') }}
          </div>
          <div class="titles" :class="num == 3 ? 'active' : ''" @click="tabShow(3)">
            {{ $t('licence.sys_trendChart') }}
          </div>
        </div>
        <!-- 根据num动态切换显示div内容 -->
        <div v-if="num == 1">
          <!-- 第一块通信模块 -->
          <table cellspacing="0" style="margin-bottom: 40px">
            <caption>
              <font>
                <h3 class="tabletitle">{{ $t('licence.sys_general') }}</h3>
              </font>
            </caption>
            <tr>
              <td bgcolor="#F6F8FA">{{ $t('licence.sys_softwareVersion') }}</td>
              <td v-if="powerStation.stationType == 1">DHN-SU1K5T-G0-SW V1.0</td>
              <td v-else>DHN-SU800D-B0-SW V1.0</td>
              <td bgcolor="#F6F8FA">{{ $t('licence.sys_hardwareVersion') }}</td>
              <td v-if="powerStation.stationType == 1">DHN-SU1K5T-G0-HW V1.0</td>
              <td v-else>DHN-SU800D-B0-HW V1.0</td>
            </tr>
          </table>
          <!-- 第二块主控制器 -->
          <table cellspacing="0" style="margin-bottom: 40px">
            <caption>
              <font>
                <h3 class="tabletitle">{{ $t('licence.sys_zkzq') }}</h3>
              </font>
            </caption>
            <tr v-if="EquipmentInfoList.mainController">
              <td bgcolor="#F6F8FA">{{ $t('licence.sys_dspyjbb') }}</td>
              <td>{{ EquipmentInfoList.mainController.dspmVersion }}</td>
              <td bgcolor="#F6F8FA">{{ $t('licence.sys_pvdy') }}</td>
              <td>
                {{ EquipmentInfoList.mainController.pvdy }}
                <el-icon @click="equipmentInformation(1, $t('licence.sys_pvdy'))" class="el-icon-bottom-left">
                  <BottomLeft />
                </el-icon>
              </td>
              <td bgcolor="#F6F8FA">{{ $t('licence.sys_pvdl') }}</td>
              <td>
                {{ EquipmentInfoList.mainController.pvdl }}
                <el-icon @click="equipmentInformation(2, $t('licence.sys_pvdl'))" class="el-icon-bottom-left">
                  <BottomLeft />
                </el-icon>
              </td>
            </tr>
            <tr v-if="EquipmentInfoList.mainController">
              <td bgcolor="#F6F8FA">{{ $t('licence.sys_mxdy') }}</td>
              <td>
                {{ EquipmentInfoList.mainController.mxdy }}
                <el-icon @click="equipmentInformation(3, $t('licence.sys_mxdy'))" class="el-icon-bottom-left">
                  <BottomLeft />
                </el-icon>
              </td>
              <td bgcolor="#F6F8FA">{{ $t('licence.sys_pvgl') }}</td>
              <td>
                {{ EquipmentInfoList.mainController.pvgl }}
                <el-icon @click="equipmentInformation(4, $t('licence.sys_pvgl'))" class="el-icon-bottom-left">
                  <BottomLeft />
                </el-icon>
              </td>
              <td bgcolor="#F6F8FA">{{ $t('licence.sys_pvzfdl') }}</td>
              <td>
                {{ EquipmentInfoList.mainController.pvzfdl }}
                <el-icon @click="equipmentInformation(5, $t('licence.sys_pvzfdl'))" class="el-icon-bottom-left">
                  <BottomLeft />
                </el-icon>
              </td>
            </tr>
            <tr v-if="EquipmentInfoList.mainController">
              <td bgcolor="#F6F8FA">{{ $t('licence.sys_jldy') }}</td>
              <td>
                {{ EquipmentInfoList.mainController.jldy }}
                <el-icon @click="equipmentInformation(6, $t('licence.sys_jldy'))" class="el-icon-bottom-left">
                  <BottomLeft />
                </el-icon>
              </td>
              <td bgcolor="#F6F8FA">{{ $t('licence.sys_jldl') }}</td>
              <td>
                {{ EquipmentInfoList.mainController.jldl }}
                <el-icon @click="equipmentInformation(7, $t('licence.sys_jldl'))" class="el-icon-bottom-left">
                  <BottomLeft />
                </el-icon>
              </td>
              <td bgcolor="#F6F8FA">{{ $t('licence.sys_nbdy') }}</td>
              <td>
                {{ EquipmentInfoList.mainController.nbdy }}
                <el-icon @click="equipmentInformation(8, $t('licence.sys_nbdy'))" class="el-icon-bottom-left">
                  <BottomLeft />
                </el-icon>
              </td>
            </tr>
            <tr v-if="EquipmentInfoList.mainController">
              <td bgcolor="#F6F8FA">{{ $t('licence.sys_bwgl') }}</td>
              <td>
                {{ EquipmentInfoList.mainController.bwgl }}
                <el-icon @click="equipmentInformation(9, $t('licence.sys_bwgl'))" class="el-icon-bottom-left">
                  <BottomLeft />
                </el-icon>
              </td>
              <td bgcolor="#F6F8FA">{{ $t('licence.sys_szgl') }}</td>
              <td>
                {{ EquipmentInfoList.mainController.szgl }}
                <el-icon @click="equipmentInformation(10, $t('licence.sys_szgl'))" class="el-icon-bottom-left">
                  <BottomLeft />
                </el-icon>
              </td>
              <td bgcolor="#F6F8FA">{{ $t('licence.sys_wggl') }}</td>
              <td>
                {{ EquipmentInfoList.mainController.wggl }}
                <el-icon @click="equipmentInformation(11, $t('licence.sys_wggl'))" class="el-icon-bottom-left">
                  <BottomLeft />
                </el-icon>
              </td>
            </tr>
            <tr v-if="EquipmentInfoList.mainController">
              <td bgcolor="#F6F8FA">{{ $t('licence.sys_glys') }}</td>
              <td>{{ EquipmentInfoList.mainController.glys }}</td>
              <td bgcolor="#F6F8FA">{{ $t('licence.sys_dwpl') }}</td>
              <td>
                {{ EquipmentInfoList.mainController.dwpl }}
                <el-icon @click="equipmentInformation(12, $t('licence.sys_dwpl'))" class="el-icon-bottom-left">
                  <BottomLeft />
                </el-icon>
              </td>
              <td bgcolor="#F6F8FA">{{ $t('licence.sys_zjlfdl') }}</td>
              <td>
                {{ EquipmentInfoList.mainController.zjlfdl }}
                <el-icon @click="equipmentInformation(13, $t('licence.sys_zjlfdl'))" class="el-icon-bottom-left">
                  <BottomLeft />
                </el-icon>
              </td>
            </tr>
            <tr v-if="EquipmentInfoList.mainController">
              <td bgcolor="#F6F8FA">{{ $t('licence.sys_zbwsj') }}</td>
              <td>{{ EquipmentInfoList.mainController.zbwsj }}</td>
              <td bgcolor="#F6F8FA">{{ $t('licence.sys_gzms') }}</td>
              <td>
                {{ EquipmentInfoList.mainController.workState }}
              </td>
              <td bgcolor="#F6F8FA">{{ $t('licence.sys_xglgzfs') }}</td>
              <td>
                {{
                  EquipmentInfoList.mainController.xglgzms
                }}
              </td>
            </tr>
            <tr v-if="EquipmentInfoList.mainController">
              <td bgcolor="#F6F8FA">{{ $t('licence.sys_zlfl') }}</td>
              <td>
                {{ EquipmentInfoList.mainController.zlfl }}
                <el-icon @click="equipmentInformation(14, $t('licence.sys_zlfl'))" class="el-icon-bottom-left">
                  <BottomLeft />
                </el-icon>
              </td>
              <td bgcolor="#F6F8FA">{{ $t('licence.sys_ldl') }}</td>
              <td>
                {{ EquipmentInfoList.mainController.ldl }}
                <el-icon @click="equipmentInformation(15, $t('licence.sys_ldl'))" class="el-icon-bottom-left">
                  <BottomLeft />
                </el-icon>
              </td>
              <td bgcolor="#F6F8FA">{{ $t('licence.sys_ryxsj') }}</td>
              <td>{{ EquipmentInfoList.mainController.ryxsj }}</td>
            </tr>
            <tr v-if="EquipmentInfoList.mainController">
              <td bgcolor="#F6F8FA">{{ $t('licence.sys_nbwd') }}(&#176;C)</td>
              <td>
                {{ EquipmentInfoList.mainController.nbwd }}
                <el-icon @click="equipmentInformation(16, $t('licence.sys_nbwd'))" class="el-icon-bottom-left">
                  <BottomLeft />
                </el-icon>
              </td>
              <td bgcolor="#F6F8FA">{{ $t('licence.sys_boostwd') }}(&#176;C)</td>
              <td>
                {{ EquipmentInfoList.mainController.boostwd }}
                <el-icon @click="equipmentInformation(17, $t('licence.sys_boostwd'))" class="el-icon-bottom-left">
                  <BottomLeft />
                </el-icon>
              </td>
              <td bgcolor="#F6F8FA">{{ $t('licence.sys_code') }}</td>
              <td>
                {{ EquipmentInfoList.mainController.cuntry }}
              </td>
            </tr>
          </table>
          <!-- 第三块故障记录-->
          <table cellspacing="0" style="margin-bottom: 40px">
            <caption>
              <font>
                <h3 class="tabletitle">{{ $t('licence.sys_control') }}</h3>
              </font>
            </caption>
            <tr v-if="EquipmentInfoList.secondaryController">
              <td bgcolor="#F6F8FA">{{ $t('licence.sys_guzhang') }}</td>
              <td>{{ EquipmentInfoList.secondaryController.fkMxdy }}</td>
              <td bgcolor="#F6F8FA">{{ $t('licence.sys_menxian') }}</td>
              <td>{{ EquipmentInfoList.secondaryController.fkJldy }}</td>
              <td bgcolor="#F6F8FA">{{ $t('licence.sys_value1') }}</td>
              <td>{{ EquipmentInfoList.secondaryController.fkJldl }}</td>
            </tr>
            <tr v-if="EquipmentInfoList.secondaryController">
              <td bgcolor="#F6F8FA">{{ $t('licence.sys_value2') }}</td>
              <td>{{ EquipmentInfoList.secondaryController.fkDwpl }}</td>
              <td bgcolor="#F6F8FA">{{ $t('licence.sys_value3') }}</td>
              <td>{{ EquipmentInfoList.secondaryController.value3 }}</td>
            </tr>
          </table>
        </div>
        <!-- 历史故障 -->
        <div v-if="num == 2">
          <el-table :data="faultData" stripe class="tableStyle">
            <el-table-column prop="num" :label="$t('licence.fau_num')" width="100">
            </el-table-column>

            <el-table-column prop="code" :label="$t('licence.fau_faultId')" width="120">
            </el-table-column>
            <el-table-column prop="faultDesc" :label="$t('licence.fau_faultDesc')">
            </el-table-column>
            <el-table-column :label="$t('licence.fau_createTime')" width="220">
              <template #default="scope">
                {{ format.FormatDate(scope.row.createTime) }}
              </template>
            </el-table-column>
            <el-table-column :label="$t('licence.fau_updateTime')" width="220">
              <template #default="scope">
                {{ format.FormatDate(scope.row.updateTime) }}
              </template>
            </el-table-column>
            <el-table-column prop="realSolution" :label="$t('licence.fau_realSolution')" width="240">
            </el-table-column>
            <el-table-column :label="$t('licence.fau_operation')" width="160">
              <template #default="scope">
                <el-button v-if="scope.row.state === 1" @click="Tosolve(scope.row)" type="text" size="small"
                  style="color: #305add">{{ $t('licence.sys_weijiejue') }}</el-button>
                <p v-if="scope.row.state === 0">{{ $t('licence.sys_yijiejue') }}</p>
              </template>
            </el-table-column>
          </el-table>
          <!-- 分页区 -->
          <div class="block" style="margin: 20px">
            <el-pagination background @size-change="handleSizeChange" @current-change="handleCurrentChange"
              :current-page="queryData.page" :page-size="queryData.pagesize" :page-sizes="[2, 4, 6, 8, 10]"
              layout="sizes, prev, pager, next,total, jumper" :total="queryData.total">
            </el-pagination>
          </div>
        </div>

        <!-- 曲线图 -->
        <div v-if="num == 3">
          <div>
            <div class="title" id="title">
              <!-- 年月日选择 -->
              <div class="time-box flexStart">
                <el-radio-group style="margin-right: 20px" v-model="radio" fill="#305ADD" border="true"
                  @change="getCharts">
                  <el-radio-button :label="1">{{ $t('licence.sta_day') }}</el-radio-button>
                  <el-radio-button :label="2">{{ $t('licence.sta_week') }}</el-radio-button>
                  <el-radio-button :label="3">{{ $t('licence.sta_month') }}</el-radio-button>
                  <el-radio-button :label="4">{{ $t('licence.sta_quarter') }}</el-radio-button>
                  <el-radio-button :label="5">{{ $t('licence.sta_year') }}</el-radio-button>
                  <el-radio-button :label="6">{{ $t('licence.sta_liyear') }}</el-radio-button>
                  <el-radio-button :label="7">{{ $t('licence.sta_calendarQuarter') }}</el-radio-button>
                </el-radio-group>
                <el-date-picker style="margin: 0 20px; width: 180px" :clearable="true" format="YYYY/MM/DD"
                  value-format="YYYY-MM-DD" v-model="searchDay.stockDate" @change="changeTime" type="date"
                  :placeholder="$t('licence.sta_selectDate')">
                </el-date-picker>
                <el-button @click="getCharts" type="primary" style="margin: 20px 0">{{
                  $t('licence.fau_Thequery') }}</el-button>
              </div>
            </div>
            <!-- 数据曲线图 -->
            <!--日则线图 -->
            <div v-show="radio <= 1">
              <!-- 发电趋势 -->
              <div class="title" id="title">
                <h3 class="big-title">{{ $t('licence.fau_Trendcurve') }}</h3>
                <div id="TrendcurveData" ref="cqjk" class="curveData"></div>
              </div>
              <!-- 电流电压 -->
              <div class="title" id="title">
                <h3 class="big-title">{{ $t('licence.fau_dataComparison') }}</h3>
                <el-checkbox-group v-model="checkedCities" style="text-align: center" :max="2">
                  <el-checkbox v-for="item  in  numberArr" :label="item.id" :key="item.id" class="MR2"
                    @change="checkInver()">{{ item.name }}</el-checkbox>
                </el-checkbox-group>
                <div id="VoltagecurveData" class="curveData"></div>
              </div>
            </div>
            <!-- 日以外柱状图 -->
            <div v-show="radio > 1">
              <div class="title" id="title">
                <h3 class="big-title">{{ $t('licence.fau_Trendcurve') }}</h3>
                <div id="ElectricityData" class="curveData"></div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </el-dialog>
    <!-- 解决弹框 -->
    <el-dialog v-model="TosolveShow" width="30%">
      <div class="titleShow">
        <div class="titles">{{ $t('licence.fau_TosolveTitle') }}</div>
      </div>
      <el-form :model="TosolveForm">
        <el-form-item :label="$t('licence.fau_TosolveSn')">
          <el-input :disabled="true" v-model="TosolveForm.sn" autocomplete="off" class="TosolveInput"></el-input>
        </el-form-item>
        <el-form-item :label="$t('licence.fau_TosolveCode')">
          <el-input :disabled="true" v-model="TosolveForm.code" autocomplete="off" class="TosolveInput"></el-input>
        </el-form-item>
        <el-form-item :label="$t('licence.fau_TosolveDesc')">
          <el-input :disabled="true" v-model="TosolveForm.faultDesc" autocomplete="off" class="TosolveInput"></el-input>
        </el-form-item>
        <el-form-item :label="$t('licence.fau_proposal')">
          <el-input :disabled="true" v-model="TosolveForm.adviseSolution" autocomplete="off"
            class="TosolveInput"></el-input>
        </el-form-item>
        <!--  -->
        <el-form-item :label="$t('licence.fau_TosolvePlan')">
          <el-input v-model="TosolveForm.realSolution" autocomplete="off" class="TosolveInput"></el-input>
        </el-form-item>
      </el-form>
      <template #footer>
        <span class="dialog-footer">
          <el-button @click="TosolveShow = false">{{ $t('licence.cancel') }}</el-button>
          <el-button type="primary" @click="determine">{{ $t('licence.determine') }}</el-button>
        </span>
      </template>
    </el-dialog>

    <!-- 设备信息里面的弹框 -->
    <el-dialog v-model="showInDialog">
      <div class="titleShow">
        <div class="titles">{{ showInDialogTitle }}</div>
      </div>
      <!-- 年月日选择 -->
      <div class="time-box flexStart">
        <div class="ri">{{ $t('licence.sta_day') }}</div>
        <div>
          <el-date-picker style="margin: 0 20px; width: 180px" :clearable="true" v-model="searchDay.stockDate" type="date"
            format="YYYY/MM/DD" value-format="YYYY-MM-DD" :placeholder="$t('licence.sta_selectDate')"
            @change="changeTime">
          </el-date-picker>
          <el-button @click="geteChartsequipment" type="primary" style="margin: 20px 0">{{
            $t('licence.fau_Thequery') }}</el-button>
        </div>
      </div>
      <div id="equipmentData" class="curveData"></div>
    </el-dialog>

    <!-- 指令下发返回弹框 -->
    <el-dialog v-model="commandReturnDialog" style="width: 40%; margin-left: 25%">
      <el-table :data="resultData.slice((currentPage - 1) * cusSize, currentPage * cusSize)"
        style="width: 100%; margin-top: 25px;" :row-class-name="tableRowClassName">
        <el-table-column prop="label" label="标签">
        </el-table-column>
        <el-table-column prop="nowValue" label="当前值">
        </el-table-column>
        <el-table-column prop="targetValue" label="目标值">
        </el-table-column>
      </el-table>
      <el-pagination @current-change="handleChangeResult" :current-page="currentPage" :page-size="cusSize"
        :total="resultData.length" small>
      </el-pagination>
    </el-dialog>

  </div>
  <el-empty :image-size="300" v-else>
    <el-button type="primary" @click="router.push({ path: 'establishDianzhan' })">{{ $t('licence.est_powerStation') }}</el-button>
  </el-empty>
</template>

<script setup lang="ts" name="Inveter">
import * as echarts from "echarts";
import format from '@/utils/format'
import { getGatewayLists } from "@/api/dianzhan/gatewayList.js";
import { getPsList, getPsListByIds, getPsInfo, getPsFaultHisList, getPsCharts, commandControl, getPsData, getGatewayCharts, } from "@/api/inveter/inveter";
import { getfaultSolve } from "@/api/fault/faultList"; //故障解决
import { getParameter, getSafetyParameter, getAllCountry, paramDelivery, getProtectParamByFirmwares, getSafetyParamByFirmwares } from "@/api/dianzhan/parameter.js"; //保护设置参数
import { getEditionLists } from "@/api/system/edition/edition"; //固件升级列表获取
import { useI18n } from 'vue-i18n'
import useStationStore from '@/store/modules/station'
const stationStore = useStationStore();
const { t } = useI18n()
const route = useRoute()
const router = useRouter()
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
interface NumberItem {
  name: string;
  id: number;
}
let numberArr = []
const env = import.meta.env.VITE_APP_ENV
const tabIndex = ref(-1)
const powerStation = ref()//获取电站信息
const GatewayList = ref([{
  gatewayName: '',
  lable: '',
  version: '',
  psNum: '',
  electricity: '',
}]) //网关列表
const gateway = ref({
  id: -1
})//网关单个
const num = ref(1)//弹框tab选择默认
// const checked = ref(false) //全选按钮
type Item = {
  isSelect: boolean;
  id: number;
  label: string,
  state: number,
  realtimePower: string,
  todayEnergy: string,
  cumulativeEnergy: string,
  dataTime: string,
  country: string,
  dcCurrent: string,
  dcVoltage: string,
  acCurrent: string,
  acVoltage: string,
  temperature: string,
  ratedPower: string,
  createTime: string,
  gatVersion: string,
}
const inverterList = ref<Item[]>([
  {
    isSelect: false,
    id: -1,
    label: '',
    state: -1,
    realtimePower: '',
    todayEnergy: '',
    cumulativeEnergy: '',
    dataTime: '',
    country: '',
    dcCurrent: '',
    dcVoltage: '',
    acCurrent: '',
    acVoltage: '',
    temperature: '',
    ratedPower: '',
    createTime: '',
    gatVersion: '',
    dspmVersion: ''
  }
]); //逆变器监控列表
const inverter = ref({
  id: -1
}) //单个逆变器
// const colorShow = ref(false) //点击样式控制
const optionsCountry = ref([
  {
    country: '',
    countryEn: '',
    code: '',
    machineCode:''
  }
])
const countryCode = ref('')
const formInlines = ref<ElFormInstance>();
// 查询状态
const options = reactive([
  { key: 0, }, { key: 1, },
  { key: 2, }, { key: 3, },
  { key: 4, },
])
const powerState = ref(0)//查询下拉绑定默认字段
const serialNumber = ref('') //输入设备序列号绑定
const showDialog = ref(false) //逆变器弹框
const showInDialog = ref(false) //设备弹框里的弹框
const showInDialogTitle = ref('') //设备弹框里的弹框
const showInDialogSubTitle = ref('') //设备弹框里的弹框
const equipmenttype = ref('') //保存设备弹框里面的点击key==type值
// 弹框的设备信息列表
const EquipmentInfoList = ref({
  mainController: {
    dspmVersion: '',
    pvdy: '',
    pvdl: '',
    mxdy: '',
    pvgl: '',
    pvzfdl: '',
    jldy: '',
    jldl: '',
    nbdy: '',
    bwgl: '',
    szgl: '',
    wggl: '',
    glys: '',
    dwpl: '',
    zjlfdl: '',
    zbwsj: '',
    workState: '',
    xglgzms: '',
    zlfl: '',
    ldl: '',
    ryxsj: '',
    nbwd: '',
    boostwd: '',
    cuntry: '',
  },
  secondaryController: {
    fkMxdy: '',
    fkJldy: '',
    fkJldl: '',
    fkDwpl: '',
    value3: '',
  }
})

const faultData = ref([]) // 弹框里面的逆变器故障列表
const gatewayFaultData = ref([]) // 弹框里面的网关故障列表
const gatewayId = ref<number | string>(0) //单个网关id 的保存
// 故障解决表单
const TosolveShow = ref(false) //故障解决弹框显示隐藏
const TosolveForm = ref({
  sn: '',
  faultId: "",
  faultDesc: "",
  realSolution: "",
  code: "",
  adviseSolution: "",
})
// 网关历史故障分页
const queryDataGateway = reactive({
  page: 1, // 当前页码
  pagesize: 10,
  total: 0, // 总数
})
// 逆变器历史故障分页
const queryData = reactive({
  page: 1, // 当前页码
  pagesize: 10,
  total: 0, // 总数
})
// 固件升级分页
const editionData = reactive({
  page: 1, // 当前页码
  pagesize: 10,
  total: 0, // 总数
})
const radioGateway = ref(1) //网关年月日默认选择
const radio = ref(1) //逆变器年月日默认选择
const selectNum = ref(0)// 选中逆变器数量
const isAllSelect = ref() // 是否全选逆变器
const commandId = ref(-1)//参数
const dialogShow0 = ref(false) //恢复出厂设置
const dialogShow1 = ref(false) //工作模式
const dialogShow2 = ref(false) //开关机控制
const dialogShow3 = ref(false) //待机时间
const dialogShow4 = ref(false) //故障恢复时间
const dialogShow5 = ref(false) //指令有功调节
const dialogShow6 = ref(false) //无功比例调节
const dialogShow7 = ref(false) //功率因数调节
const dialogShow8 = ref(false) //保护设置
const dialogShow8Check = ref(false) //保护设置
const dialogShow9 = ref(false) //刷新时间
const dialogShow10 = ref(false) //固件升级
const dialogShow11 = ref(false) //固定有功调节
const dialogShow12 = ref(false) //安规参数
const dialogShow12Check = ref(false) //安规参数
const dialogShow13 = ref(false) //自检设置
const dialogShow13Check = ref(false) //自检设置
const pattern = ref(1) //工作模式
const open = ref('1') //开关机控制
const switchO = ref<number | string>(1) //指令有功调节控制
const switchT = ref<number | string>(1) //无功比例调节控制
const switchS = ref<number | string>(1) //功率因数调节控制
const switchG = ref<number | string>(1) //固定有功调节
const formInline = ref({
  num_0: '' as any,
  //待机时间 故障恢复时间
  num_1: '' as any,
  num_2: '' as any,
  num_3: '' as any,
  num_4: '' as any, //固定有功调节
  num_5: '' as any,
  num_6: '' as any,
  num_8_0: '' as any,
  num_12_0: '' as any,
  refreshTime: "",
})
const rules = reactive({
  num1: [
    {
      required: true,
      message: t("licence.sys_shurushuzhi"),
      trigger: "blur",
    },
  ],
  num2: [
    {
      required: true,
      message: t("licence.sys_shurushuzhi"),
      trigger: "blur",
    },
  ],
  num3: [
    {
      required: true,
      message: t("licence.sys_shurushuzhi"),
      trigger: "blur",
    },
  ],
  num4: [
    {
      required: true,
      message: t("licence.sys_shurushuzhi"),
      trigger: "blur",
    },
  ],
  num_0: [
    {
      required: true,
      message: t("licence.sys_shurushuzhi"),
      trigger: "blur",
    },
    {
      pattern: /^(?:0|[1-9][0-9]?|200)$/,
      message: "最大数值0-200之间",
      trigger: "blur",
    },
  ],
  num_1: [
    {
      required: true,
      message: t("licence.sys_shurushuzhi"),
      trigger: "blur",
    },
  ],
  num_2: [
    {
      required: true,
      message: t("licence.sys_shurushuzhi"),
      trigger: "blur",
    },
  ],
  num_3: [
    {
      required: true,
      message: t("licence.sys_shurushuzhi"),
      trigger: "blur",
    },
  ],
  num_4: [
    {
      required: true,
      message: t("licence.sys_shurushuzhi"),
      trigger: "blur",
    },
  ],
  num_5: [
    {
      required: true,
      message: t("licence.sys_shurushuzhi"),
      trigger: "blur",
    },
  ],
  num_6: [
    {
      required: true,
      message: t("licence.sys_shurushuzhi"),
      trigger: "blur",
    },
  ],
  refreshTime: [
    {
      required: true,
      message: t("licence.sys_shurushuzhi"),
      trigger: "blur",
    },
    {
      pattern: /^[2-8]*$/,
      message: t("licence.sys_zuida"),
      trigger: "blur",
    },
  ],
});
//保护参数设置保存
const parameterData = ref({
  country: '',
  faultOneHight: '' as any,
  faultOneLow: '' as any,
  faulTwoHight: '' as any,
  faultTwoLow: '' as any,
  faultThreeHight: '' as any,
  faultThreeLow: '' as any,
  protectEnable: '' as any,
  protectOneSection: '' as any,
  protectOneSectionTime: '' as any,
  protectTwoSection: '' as any,
  protectTwoSectionTime: '' as any,
  recoveryValue: '' as any,
  overvoltage: '' as any,
  overcurrentThreshold: '' as any,
  instantThreshold: '' as any,
  componentThreshold: '' as any,
  oLThreshold: '' as any,
  vDThreshold: '' as any,
  uvOneSection: '' as any,
  uvOneSectionTime: '' as any,
  uvTwoSection: '' as any,
  uvTwoSectionTime: '' as any,
  uvValue: '' as any,
  boostThreshold: '' as any,
  invthreshold: '' as any,
  pvthreshold: '' as any,
  pvstopThreshold: '' as any,
  pvhightThreshold: '' as any,
  pvothreshold: '' as any,
  pqOneSection: '' as any,
  pqOneSectionTime: '' as any,
  pqRecoveryValue: '' as any,
  psVoltageKp: '' as any,
  psVoltageKi: '' as any,
  psCurrentKp: '' as any,
  psCurrentKi: '' as any,
  boostVoltageKp: '' as any,
  boostVoltageKi: '' as any,
  boostCurrentKp: '' as any,
  boostCurrentKi: '' as any,
  uqOneSection: '' as any,
  uqOneSectionTime: '' as any,
  uqRecoveryValue: '' as any,
  reserveOne: '' as any,
  reserveTwo: '' as any,
})
//保护参数设置保存
const safetyParameterData = ref({
  minCos: '' as any,
  country: '' as any,
  pigMinV: '' as any,
  pigMaxV: '' as any,
  pigMinF: '' as any,
  pigMaxF: '' as any,
  reconnectWait: '' as any,
  startWait: '' as any,
  riseSlope: '' as any,
  puCurveEnable: '' as any,
  puCurveStartV: '' as any,
  puCurveEndV: '' as any,
  puCurveResTime: '' as any,
  puCurveResDelay: '' as any,
  ofEnable: '' as any,
  ofPoint: '' as any,
  ofSlope: '' as any,
  ofResDelay: '' as any,
  reactiveEnable: '' as any,
  quCurveStartUv: '' as any,
  quCurveEndUv: '' as any,
  quCurveStartOv: '' as any,
  quCurveEndOv: '' as any,
  quCurveResTime: '' as any,
  quCurveResDelay: '' as any,
  fixedPowerFactorValue: '' as any,
  reactivePowerRatioValue: '' as any,
  pfCurveStartPercent: '' as any,
  pfCurveEndPercent: '' as any,
  lcEnable: '' as any,
  lcCurveVoltageOne: '' as any,
  lcCurveVoltageOneTime: '' as any,
  lcCurveVoltageTwo: '' as any,
  lcCurveVoltageTwoTime: '' as any,
})
const editionList = ref([]) //固件升级信息列表
const editionRadio = ref('')
const upgradeForm = ref({
  remark: ''
})
const inverterId = ref('') //固件升级
const gatewayDialog = ref(false) // 网关弹框
const gatewaynum = ref(1) //网关双击之后tab默认第一个
const timer = ref() //定时器名称
const gatewayTime = ref()
const lang = ref(1)
let userInfo = reactive({
  dept: {
    countryCode: ''
  }
})
// statusKey: null, //保存其他页面跳转查询状态的值
// 逆变器的多元化比较 多选框绑定=======
const checkedCities = ref([1, 2])
const showByType = ref(false)
const commandReturnDialog = ref(false)
const pagesize = ref(10)    //默认分页每页数据量
const currentPage = ref(1) //默认展示第一页数据
const cusSize = ref(20)
const resultList = ref([])
const resultData = ref([{
          label: '2016-05-02',
          nowValue: '13',
          targetValue: '6',
        }, {
          label: '2016-05-04',
          nowValue: '13',
          targetValue: '6'
        }, {
          label: '2016-05-01',
          nowValue: '13',
          targetValue: '6',
        }, {
          label: '2016-05-03',
          nowValue: '13',
          targetValue: '6'
        }])

// 时间选择器
const getNowTime = (): string => {
  const now = new Date();
  const year = now.getFullYear();
  const month = now.getMonth() + 1;
  const date = now.getDate();

  const defaultDate = `${year}-${month.toString().padStart(2, '0')}-${date.toString().padStart(2, '0')}`;
  return defaultDate;
}
const searchDay = ref({
  stockDate: getNowTime(),
}) //日期选择
const selfTestList = [
  {
    label: t("licence.inv_type4"),
    data: '230.2V'
  }, {
    label: t("licence.inv_type5"),
    data: '3.47A'
  }, {
    label: t("licence.inv_type0"),
    data: '798W'
  }, {
    label: t("licence.sys_pl"),
    data: '50.01Hz'
  }
]
const testReport = [{
  label: '59.S2 threshold 264.5V 200ms',
  data: '59.S2:266.0V 212ms',
  Result: 'pass'
}, {
  label: '27.S1 threshold 184V 400ms',
  data: '27.S1:183.4V 403ms',
  Result: 'pass'
}, {
  label: '81>.S2 threshold 51.5Hz 100ms',
  data: '81>.S2 51.51Hz 92ms',
  Result: 'pass'
}, {
  label: '81<.S2 threshold 47.5Hz 100ms',
  data: '81<.S2 47.49Hz 95ms',
  Result: 'pass'
}]
onMounted(() => {
  powerStation.value = stationStore.powerStation;
  if(!powerStation.value) return
  {
    if (route.query.statusKey) {
      powerState.value = Number(route.query.statusKey);
    }
    if (timer.value) {
      clearInterval(timer.value);
    } else {
      timer.value = setInterval(() => {
        getGatewayList(); //网关
        getInverterList(); //逆变器
      }, 3000 * 60);
    }
    // 获取语言
    if (localStorage.getItem("locale") == "en_US") {
      lang.value = 1;
      numberArr = [{
        id:1,
        name:'power',
        unit: 'power(W)',
        count:2
      },{
        id:2,
        name:'power generation',
        unit: 'power generation(kWh)',
        count:1
      },{
        id:3,
        name:'voltage',
        unit: 'voltage(V)',
        count:3
      },{
        id:4,
        name:'current',
        unit: 'current(A)',
        count:2
      },{
        id:5,
        name:'temperature',
        unit: 'temperature(℃)',
        count:2
      },{
        id:6,
        name:'power factor',
        unit:'',
        count:1
      },{
        id:7,
        name:'Leakage current',
        unit:'Leakage current(mA)',
        count:1
      }]
    } else {
      lang.value = 0;
      numberArr =[{
        id:1,
        name:'功率',
        unit: '功率(W)',
        count:2
      },{
        id:2,
        name:'发电量',
        unit: '发电量(kWh)',
        count:1
      },{
        id:3,
        name:'电压',
        unit: '电压V',
        count:3
      },{
        id:4,
        name:'电流',
        unit: '电流A',
        count:2
      },{
        id:5,
        name:'温度',
        unit: '温度C',
        count:2
      },{
        id:6,
        name:'功率因数',
        unit:'',
        count:1
      },{
        id:7,
        name:'漏电流',
        unit:'漏电流(mA)',
        count:1
      }]
    }
    //
    userInfo = JSON.parse(localStorage.getItem("userInfo") as string);
    // 获取电站信息
    getstation()
  }
})
const tableRowClassName = ({row, rowIndex}:any) => {
      if (row.nowValue != row.targetValue) {
        return 'warning-row';
      }
      return '';
}
const compareResult = (value:any) => {
  currentPage.value = 1
  resultData.value = []
  if(commandId.value == 0) {
    resultList.value.forEach((item) => {
      let result = {
        label: item.lable,
        nowValue: item.cuntry,
        targetValue: value
      }
      resultData.value.push(result)
    })
  } else  if (commandId.value == 11) {
    resultList.value.forEach((item) => {
      let result = {
        label: item.lable,
        nowValue: item.xglgzms,
        targetValue: value
      }
      resultData.value.push(result)
    })
  }
  commandReturnDialog.value = true
}
const handleChangeResult = (currentPage:any) => {
  currentPage.value = currentPage;
}
const getstation = async () => {
  if (powerStation.value&&powerStation.value.stationType != 3) {
    showByType.value = true
  }
  proxy!.$forceUpdate();
  // 获取网关列表
  getGatewayList();
  getInverterList();
  checkedAll();
}
const selectChanged = (value: any) => {
  if (
    route.query.statusKey == undefined ||
    route.query.statusKey
  ) {
    powerState.value = value;
    getInverterList(); //逆变器
  }
}

const changeTime = (val: any) => {
  proxy!.$forceUpdate(); //需要使用强制更新
  searchDay.value.stockDate = val;
}
// 获取网关列表
const getGatewayList = async () => {
  let res = await getGatewayLists(powerStation.value.id);
  GatewayList.value = res.data;
}
// tab网关切换
//单击网关 获取电站/网关下的逆变器
const tabClick = async (index: any, item: any) => {
  clearTimeout(gatewayTime.value);
  gatewayTime.value = setTimeout(() => {
    selectNum.value = 0;
    if (selectNum.value == 0) {
      isAllSelect.value = t("licence.sys_selectAll");
    }
    tabIndex.value = index;
    gateway.value = item;
    getInverterList();
  }, 300);
}
// 双击网关
const gatewayShow = (item: any) => {
  gatewayId.value = item.id;
  clearTimeout(gatewayTime.value);
  gatewayDialog.value = true;
  gatewayTabShow(1);
}
// 网关弹框的tab切换
const gatewayTabShow = async (key: any) => {
  gatewaynum.value = key;
  if (gatewaynum.value == 1) {
    //历史故障
    getGatewayFaultData();
  } else {
    // 曲线图
    getChartsGateway();
  }
}
// 获取逆变器列表
const getInverterList = async () => {
  let query = {
    state: powerState.value - 1,
    psSn: serialNumber.value,
    gatId: "",
    stationId: powerStation.value.id,
    lang: lang.value,
  };
  let res = await getPsList(query);
  inverterList.value = res.data;
  // }
  //每一个数据添加一个字段  用来判断这个数据是否选择
  inverterList.value.forEach((item) => {
    item.isSelect = false; // 默认都未选择 false
  });
}
//单击事件  选择逆变器
const actives = (index: any, item: any) => {
  clearTimeout(timer.value);
  timer.value = setTimeout(() => {
    // inverterList 所有数据  isSelect这个是tru不就是选中的吗
    inverterList.value.forEach((item, idx) => {
      if (index == idx) {
        item.isSelect = !item.isSelect;
      }
    });
    selectNum.value = 0;
    // 在所有数据里面找  凡是  item.isSelect = true的是选中的 有一个就加1
    inverterList.value.forEach((item) => {
      if (item.isSelect) {
        // 如果是true
        selectNum.value++;
      }
    });
    // 点击的时候 改对应的数据
  }, 300);
}
// 双击弹框显示 获取单个逆变器 // 弹框的设备信息列表
const EquipmentShow = (item: any) => {
  clearTimeout(timer.value);
  inverter.value = item;
  tabShow(1);
  showDialog.value = true;
}
// 立即刷新指令
const refreshAll = () => {
  if (gateway.value) {
    let data = {
      stationId: powerStation.value.id,
      commandId: 12,
      ids: gateway.value.id,
      lang: lang.value,
    };
    commandControl(data);
  } else {
    let data = {
      stationId: powerStation.value.id,
      commandId: 12,
      ids: -1,
      lang: lang.value,
    };
    commandControl(data);
  }
  if(env=='staging'){
    ElMessage({
      type: "success",
      duration: 15000,
      message: t("licence.sys_refreshTips"),
    });
  }
  else ElMessage({
    type: "success",
    message: t("licence.sys_refreshTips"),
  });
  setTimeout(() => {
    getInverterList(); //逆变器
  }, 15000);
}
// 全选
const checkedAll = () => {
  //要切换，有个值来判断是全选或者取消全选 定义看一个isAllSelect false默认该全选
  // 点击的时候判断去判断一下
  if (isAllSelect.value) {
    // 全选 全部选中
    selectNum.value = 0;
    inverterList.value.forEach((item) => {
      item.isSelect = true;
      selectNum.value++;
    });
  } else {
    // 取消全选  全部取消全选  这个要为 selectNum.value = 0 因为没有选中的了
    selectNum.value = 0;
    inverterList.value.forEach((item) => {
      item.isSelect = false;
    });
  }
  isAllSelect.value = !isAllSelect.value;
}
// 参数下发
// (参数弹框)
const dialogClick0 = (name: any) => {
  showInDialogTitle.value = name;
  dialogShow0.value = true;
  formInline.value.num_0 = "";
}
const dialogClick2 = (name: any) => {
  showInDialogTitle.value = name;
  dialogShow2.value = true;
  open.value = "1"; //开关机控制
}
const dialogClick5 = (name: any) => {
  showInDialogTitle.value = name;
  dialogShow5.value = true;
  formInline.value.num_3 = "";
  switchO.value = "1"; //指令有功调节控制
}
const dialogClick7 = (name: any) => {
  showInDialogTitle.value = name;
  dialogShow7.value = true;
  formInline.value.num_5 = "";
  switchS.value = "1"; //功率因数调节控制
}
const dialogClick8 = async (name: any) => {
  // 获取国家
  getAdd();
  showInDialogTitle.value = name;
  dialogShow8.value = true;
  let res = await getParameter({
    code: userInfo.dept.countryCode,
  });
  parameterData.value = res.data;
}
const dialogClick8Check = (name: any) => {
  formInline.value.num_8_0 = "";
  showInDialogSubTitle.value = name;
  dialogShow8Check.value = true;
}
const dialogClick10 = (name: any) => {
  let ids = [];
  // 收集所有被选择的id
  inverterList.value.forEach((item) => {
    if (item.isSelect) {
      ids.push(item.id);
    }
  });
  showInDialogTitle.value = name;
  dialogShow10.value = true;
  getEditionList();
}
const dialogClick11 = (name: any) => {
  showInDialogTitle.value = name;
  dialogShow11.value = true;
  formInline.value.num_6 = "";
  switchG.value = "1"; //固定有功调节
}
const dialogClick12 = async (name: any) => {
  showInDialogTitle.value = name;
  dialogShow12.value = true;
  let res = await getSafetyParameter({
    code: userInfo.dept.countryCode,
  });
  safetyParameterData.value = res.data;
}
const dialogClick12Check = (name: any) => {
  formInline.value.num_12_0 = "";
  showInDialogSubTitle.value = name;
  dialogShow12Check.value = true;
}
const dialogClick13 = async (name: any) => {
  showInDialogTitle.value = name;
  dialogShow13.value = true;
}
const dialogClick13Check = (name: any) => {
  showInDialogSubTitle.value = name;
  dialogShow13Check.value = true;
}
const convertArrayOfObjectsToCSV = (data: any) => {
  const csvRows = [];
  const headers = Object.keys(data[0]);
  // const headers = ['Setting point','Self-test','Result'];
  // 添加表头
  csvRows.push(headers.join(','));
  // 添加表格数据
  for (const row of data) {
    const values = headers.map(header => {
      const escapeQuotes = row[header]
      return `"${escapeQuotes}"`;
    });
    csvRows.push(values.join(','));
  }

  // 返回CSV内容
  return csvRows.join('\n');
}
// 将自检报告导出为csv
const exportToCSV = () => {
  // 将表格数据转化为CSV格式
  let keyMapping = {}
  if (localStorage.getItem("locale") == "en") {
    keyMapping = {
      label: 'Setting point',
      data: 'Self-test',
      Result: 'Result',
    }
  } else {
    keyMapping = {
      label: '设置点',
      data: '自检结果',
      Result: '状态',
    }
  }

  const modifiedTableData: any = []
  testReport.map(obj => {
    const modifiedObj = {};
    for (let key in obj) {
      if (keyMapping.hasOwnProperty(key)) {
        const newKey = keyMapping[key];
        modifiedObj[newKey] = obj[key];
      } else {
        modifiedObj[key] = obj[key];
      }
    }
    modifiedTableData.push(modifiedObj)
  });
  const csvContent = convertArrayOfObjectsToCSV(modifiedTableData);
  // 创建下载链接，用于下载生成的CSV文件
  const blob = new Blob([csvContent], { type: 'text/csv;charset=utf-8;' });
  const link = document.createElement('a');
  if (link.download !== undefined) {
    const url = URL.createObjectURL(blob);
    link.setAttribute('href', url);
    link.setAttribute('download', 'data.csv');
    link.style.visibility = 'hidden';
    document.body.appendChild(link);
    link.click();
    document.body.removeChild(link);
  }
}
// 获取国家
const getAdd = async () => {
  let res = await getAllCountry();
  optionsCountry.value = res.data;
}
// 切换国家获取参数
const countryChanged = async (value: any) => {
  let res = await getParameter({
    code: value,
  });
  parameterData.value = res.data;
}
const prepareParam = () => {
  let ids: number[] = [];
  // 收集所有被选择的id
  inverterList.value.forEach((item) => {
    if (item.isSelect) {
      ids.push(item.id);
    }
  });
  if (ids.length != 1) {
    return 0;
  } else {
    return ids[0];
  }
}
// 读取固件获取参数
const getSafetyParamByFirmware = async () => {
  let id = await prepareParam();
  if (id == 0) {
    ElMessage({
      type: "warning",
      message: t("licence.onlySingle"),
    });
    return
  }
  let data = {
    stationId: powerStation.value.id,
    commandId: 14,
    ids: id,
    lang: lang.value,
  };
  commandControl(data)
    .then(res => {
      const loading = ElLoading.service({
        lock: true,
        text: 'Loading',
        spinner: 'el-icon-loading',
        background: 'rgba(0, 0, 0, 0.7)'
      });
      setTimeout(() => {
        getSafetyParamByFirmwares({
          id: id,
        }).then(res => {
          safetyParameterData.value = res.data;
          loading.close();
        }).catch(err => {
          loading.close();
          return
        });;
      }, 5000);
    })
    .catch(err => {
      return
    })
}
const getProtectParamByFirmware = async () => {
  let id = await prepareParam();
  if (id == 0) {
    ElMessage({
      type: "warning",
      message: t("licence.onlySingle"),
    });
    return
  }
  let data = {
    stationId: powerStation.value.id,
    commandId: 15,
    ids: id,
    lang: lang.value,
  };
  commandControl(data)
    .then(res => {
      const loading = ElLoading.service({
        lock: true,
        text: 'Loading',
        spinner: 'el-icon-loading',
        background: 'rgba(0, 0, 0, 0.7)'
      });
      setTimeout(() => {
        let that = this
        let res = getProtectParamByFirmwares({
          id: id,
        })
          .then(res => {
            parameterData.value = res.data;
            countryCode.value = parameterData.value.country
            loading.close();
          })
          .catch(err => {
            loading.close();
            return
          });
      }, 5000);
    })
    .catch(err => {
      return
    });

}
// 固件升级获取列表
const getEditionList = async () => {
  let res = await getEditionLists({
    pageNo: editionData.page,
    pageSize: editionData.pagesize,
    type: 2,
  });
  editionData.total = res.data.total;
  editionList.value = res.data.list;
}
// 分页
const editionSizeChange = (val: any) => {
  editionData.pagesize = val;
  getfaultData();
}
const editionCurrentChange = (val: any) => {
  editionData.page = val;
  getfaultData();
}
const getCurrentRow = (row: any) => {
  inverterId.value = row.id;
}
const instruction = async (key: any) => {
  commandId.value = key;
  let ids: number[] = [];
  // 收集所有被选择的id
  inverterList.value.forEach((item) => {
    if (item.isSelect) {
      ids.push(item.id);
    }
  });

  // 恢复出厂设置
  if (commandId.value == 0) {
    await formInlines.value?.validate();
    ElMessageBox.confirm(t("licence.recovery"), t("licence.Tips"), {
      confirmButtonText: t("licence.determine"),
      cancelButtonText: t("licence.cancel"),
      type: "warning",
    })
      .then(async () => {
        let data = {
          commandId: commandId.value,
          ids: ids.join(","),
          setVal: formInline.value.num_0,
          lang: lang.value,
        };
        await commandControl(data);
        // 车间特有
        if(env=='staging'){
            if(formInline.value.num_0 > 20) {
                ElMessage({
                  type: "success",
                  message: t("licence.success"),
                });
            } else {
              ElMessage({
                type: "success",
                duration: 40000,
                message: t("licence.sys_restoreFactory_compare"),
              });
              setTimeout(async () => {
                let data = {
                  stationId: powerStation.value.id,
                  commandId: 12,
                  ids: -1,
                  lang: lang.value,
                };
                commandControl(data);
              }, 30000);
              setTimeout(async () => {
                let res = await getPsListByIds(ids.join(","));
                console.log(res)
                resultList.value = res.data;
                compareResult(formInline.value.num_0);
              }, 40000);
            }
        }
        else ElMessage({
          type: "success",
          message: t("licence.success"),
        });
      })
      .catch(() => {
        ElMessage({
          type: "info",
          message: t("licence.cancels"),
        });
      });
    dialogShow0.value = false;
  }
  //======工作模式
  if (commandId.value === 1) {
    ElMessageBox.confirm(t("licence.Submit"), t("licence.Tips"), {
      confirmButtonText: t("licence.determine"),
      cancelButtonText: t("licence.cancel"),
      type: "warning",
    })
      .then(async () => {
        let data = {
          commandId: commandId.value,
          ids: ids.join(","),
          type: pattern.value,
          lang: lang.value,
        };
        await commandControl(data);
        ElMessage({
          type: "success",
          message: t("licence.success"),
        });
      })
      .catch(() => {
        ElMessage({
          type: "info",
          message: t("licence.cancels"),
        });
      });
    dialogShow1.value = false;
  }
  //====== 开关机控制
  if (commandId.value === 2) {
    ElMessageBox.confirm(t("licence.Submit"), t("licence.Tips"), {
      confirmButtonText: t("licence.determine"),
      cancelButtonText: t("licence.cancel"),
      type: "warning",
    })
      .then(async () => {
        let data = {
          commandId: commandId.value,
          ids: ids.join(","),
          type: open.value,
          lang: lang.value,
        };
        await commandControl(data);
        ElMessage({
          type: "success",
          message: t("licence.success"),
        });
      })
      .catch(() => {
        ElMessage({
          type: "info",
          message: t("licence.cancels"),
        });
      });
    dialogShow2.value = false;
  }
  //====== 待机时间
  if (commandId.value == 3) {
    await formInlines.value?.validate();
    if (formInline.value.num_1 >= 0 && formInline.value.num_1 <= 32767) {
      ElMessageBox.confirm(t("licence.Submit"), t("licence.Tips"), {
        confirmButtonText: t("licence.determine"),
        cancelButtonText: t("licence.cancel"),
        type: "warning",
      })
        .then(async () => {
          let data = {
            commandId: commandId.value,
            ids: ids.join(","),
            standbyTime: formInline.value.num_1,
            lang: lang.value,
          };
          await commandControl(data);
          ElMessage({
            type: "success",
            message: t("licence.success"),
          });
        })
        .catch(() => {
          ElMessage({
            type: "info",
            message: t("licence.cancels"),
          });
        });
      dialogShow3.value = false;
      dialogShow4.value = false;
    } else {
      ElMessage({
        type: "error",
        message: t("licence.sys_shuzhi3"),
      });
    }
  }
  //====== 故障恢复时间
  if (commandId.value == 4) {
    await formInlines.value?.validate();
    if (formInline.value.num_2 >= 0 && formInline.value.num_2 <= 32767) {
      ElMessageBox.confirm(t("licence.Submit"), t("licence.Tips"), {
        confirmButtonText: t("licence.determine"),
        cancelButtonText: t("licence.cancel"),
        type: "warning",
      })
        .then(async () => {
          let data = {
            commandId: commandId.value,
            ids: ids.join(","),
            standbyTime: formInline.value.num_2,
            lang: lang.value,
          };
          await commandControl(data);
          ElMessage({
            type: "success",
            message: t("licence.success"),
          });
        })
        .catch(() => {
          ElMessage({
            type: "info",
            message: t("licence.cancels"),
          });
        });
      dialogShow3.value = false;
      dialogShow4.value = false;
    } else {
      ElMessage({
        type: "error",
        message: t("licence.sys_shuzhi3"),
      });
    }
  }
  //====== 指令有功调节
  if (commandId.value == 5) {
    if (switchO.value == 1) {
      await formInlines.value?.validate();
      if (formInline.value.num_3 > 0) {
        ElMessageBox.confirm(t("licence.Submit"), t("licence.Tips"), {
          confirmButtonText: t("licence.determine"),
          cancelButtonText: t("licence.cancel"),
          type: "warning",
        })
          .then(async () => {
            let data = {
              commandId: commandId.value,
              ids: ids.join(","),
              setVal: formInline.value.num_3,
              type: switchO.value,
              lang: lang.value,
            };
            await commandControl(data);
            ElMessage({
              type: "success",
              message: t("licence.success"),
            });
          })
          .catch(() => {
            ElMessage({
              type: "info",
              message: t("licence.cancels"),
            });
          });
        dialogShow5.value = false;
      } else {
        ElMessage({
          type: "error",
          message: t("licence.sys_shuzhi0"),
        });
      }
    } else {
      ElMessageBox.confirm(t("licence.Submit"), t("licence.Tips"), {
        confirmButtonText: t("licence.determine"),
        cancelButtonText: t("licence.cancel"),
        type: "warning",
      })
        .then(async () => {
          let data = {
            commandId: commandId.value,
            ids: ids.join(","),
            // setVal: formInline.value.num_3,
            type: switchO.value,
            lang: lang.value,
          };
          await commandControl(data);
          ElMessage({
            type: "success",
            message: t("licence.success"),
          });
        })
        .catch(() => {
          ElMessage({
            type: "info",
            message: t("licence.cancels"),
          });
        });
      dialogShow5.value = false;
    }
  }
  //====== 无功比例调节
  if (commandId.value == 6) {
    if (switchT.value == 1) {
      await formInlines.value?.validate();
      if (formInline.value.num_4 >= 0 && formInline.value.num_4 <= 1000 || formInline.value.num_4 == 3003 || formInline.value.num_4 == 3276) {
        ElMessageBox.confirm(t("licence.Submit"), t("licence.Tips"), {
          confirmButtonText: t("licence.determine"),
          cancelButtonText: t("licence.cancel"),
          type: "warning",
        })
          .then(async () => {
            let data = {
              commandId: commandId.value,
              ids: ids.join(","),
              setVal: formInline.value.num_4,
              type: switchT.value,
              lang: lang.value,
            };
            await commandControl(data);
            ElMessage({
              type: "success",
              message: t("licence.success"),
            });
          })
          .catch(() => {
            ElMessage({
              type: "info",
              message: t("licence.cancels"),
            });
          });
        dialogShow6.value = false;
      } else {
        ElMessage({
          type: "error",
          message: t("licence.sys_shuzhi3276"),
        });
      }
    } else {
      ElMessageBox.confirm(t("licence.Submit"), t("licence.Tips"), {
        confirmButtonText: t("licence.determine"),
        cancelButtonText: t("licence.cancel"),
        type: "warning",
      })
        .then(async () => {
          let data = {
            commandId: commandId.value,
            ids: ids.join(","),
            // setVal: formInline.value.num_4,
            type: switchT.value,
            lang: lang.value,
          };
          await commandControl(data);
          ElMessage({
            type: "success",
            message: t("licence.success"),
          });
        })
        .catch(() => {
          ElMessage({
            type: "info",
            message: t("licence.cancels"),
          });
        });
      dialogShow6.value = false;
    }
  }
  //====== 功率因数调节
  if (commandId.value == 7) {
    if (switchS.value == 1) {
      await formInlines.value?.validate();
      if (
        (formInline.value.num_5 >= -1000 && formInline.value.num_5 <= -900) ||
        (formInline.value.num_5 >= 900 && formInline.value.num_5 <= 1000)
      ) {
        ElMessageBox.confirm(t("licence.Submit"), t("licence.Tips"), {
          confirmButtonText: t("licence.determine"),
          cancelButtonText: t("licence.cancel"),
          type: "warning",
        })
          .then(async () => {
            let data = {
              commandId: commandId.value,
              ids: ids.join(","),
              setVal: formInline.value.num_5,
              type: switchS.value,
              lang: lang.value,
            };
            await commandControl(data);
            ElMessage({
              type: "success",
              message: t("licence.success"),
            });
          })
          .catch(() => {
            ElMessage({
              type: "info",
              message: t("licence.cancels"),
            });
          });
        dialogShow7.value = false;
      } else {
        ElMessage({
          type: "error",
          message: t("licence.sys_gonglv9"),
        });
      }
    } else {
      ElMessageBox.confirm(t("licence.Submit"), t("licence.Tips"), {
        confirmButtonText: t("licence.determine"),
        cancelButtonText: t("licence.cancel"),
        type: "warning",
      })
        .then(async () => {
          let data = {
            commandId: commandId.value,
            ids: ids.join(","),
            // setVal: formInline.value.num_5,
            type: switchS.value,
            lang: lang.value,
          };
          await commandControl(data);
          ElMessage({
            type: "success",
            message: t("licence.success"),
          });
        })
        .catch(() => {
          ElMessage({
            type: "info",
            message: t("licence.cancels"),
          });
        });
      dialogShow7.value = false;
    }
  }
  //======  保护设置
  if (commandId.value == 8) {
    if (formInline.value.num_8_0 != 123456) {
      ElMessage({
        type: "error",
        message: t("licence.pass_fail"),
      });
      return
    }
    if (parameterData.value.faultOneHight > 65536 ||
      parameterData.value.faultOneLow > 65536 ||
      parameterData.value.faulTwoHight > 65536 ||
      parameterData.value.faultTwoLow > 65536 ||
      parameterData.value.faultThreeHight > 65536 ||
      parameterData.value.faultThreeLow > 65536) {
      ElMessage({
        type: "error",
        message: t("licence.sys_shuzhi65536"),
      });
    }
    if (
      parameterData.value.protectEnable <= 32767 &&
      parameterData.value.protectOneSection <= 32767 &&
      parameterData.value.protectOneSectionTime <= 32767 &&
      parameterData.value.protectTwoSection <= 32767 &&
      parameterData.value.protectTwoSectionTime <= 32767 &&
      parameterData.value.recoveryValue <= 32767 &&
      parameterData.value.overvoltage <= 32767 &&
      parameterData.value.overcurrentThreshold <= 32767 &&
      parameterData.value.instantThreshold <= 32767 &&
      parameterData.value.componentThreshold <= 32767 &&
      parameterData.value.oLThreshold <= 32767 &&
      parameterData.value.vDThreshold <= 32767 &&
      parameterData.value.uvOneSection <= 32767 &&
      parameterData.value.uvOneSectionTime <= 32767 &&
      parameterData.value.uvTwoSection <= 32767 &&
      parameterData.value.uvTwoSectionTime <= 32767 &&
      parameterData.value.uvValue <= 32767 &&
      parameterData.value.boostThreshold <= 32767 &&
      parameterData.value.invthreshold <= 32767 &&
      parameterData.value.pvthreshold <= 32767 &&
      parameterData.value.pvstopThreshold <= 32767 &&
      parameterData.value.pvhightThreshold <= 32767 &&
      parameterData.value.pvothreshold <= 32767 &&
      parameterData.value.pqOneSection <= 32767 &&
      parameterData.value.pqOneSectionTime <= 32767 &&
      parameterData.value.pqRecoveryValue <= 32767 &&
      parameterData.value.psVoltageKp <= 32767 &&
      parameterData.value.psVoltageKi <= 32767 &&
      parameterData.value.psCurrentKp <= 32767 &&
      parameterData.value.psCurrentKi <= 32767 &&
      parameterData.value.boostVoltageKp <= 32767 &&
      parameterData.value.boostVoltageKi <= 32767 &&
      parameterData.value.boostCurrentKp <= 32767 &&
      parameterData.value.boostCurrentKi <= 32767 &&
      parameterData.value.uqOneSection <= 32767 &&
      parameterData.value.uqOneSectionTime <= 32767 &&
      parameterData.value.uqRecoveryValue <= 32767 &&
      parameterData.value.reserveOne <= 32767 &&
      parameterData.value.reserveTwo <= 32767
    ) {
      ElMessageBox.confirm(t("licence.Submit"), t("licence.Tips"), {
        confirmButtonText: t("licence.determine"),
        cancelButtonText: t("licence.cancel"),
        type: "warning",
      })
        .then(async () => {
          let data = {
            commandId: commandId.value,
            ids: ids.join(","),
            parameters: parameterData.value,
            lang: lang.value,
          };
          await commandControl(data);
          ElMessage({
            type: "success",
            message: t("licence.success"),
          });
        })
        .catch(() => {
          ElMessage({
            type: "info",
            message: t("licence.cancels"),
          });
        });
      dialogShow8.value = false;
      dialogShow8Check.value = false;
    } else {
      ElMessage({
        type: "error",
        message: t("licence.sys_shuzhi3"),
      });
    }
  }
  //======  刷新时间
  if (commandId.value == 9) {
    await formInlines.value?.validate();
    ElMessageBox.confirm(t("licence.SubmitTime"), t("licence.Tips"), {
      confirmButtonText: t("licence.determine"),
      cancelButtonText: t("licence.cancel"),
      type: "warning",
    })
      .then(async () => {
        let data = {
          commandId: commandId.value,
          ids: ids.join(","),
          standbyTime: formInline.value.refreshTime,
          stationId: powerStation.value.id,
          lang: lang.value,
        };
        await commandControl(data);
        ElMessage({
          type: "success",
          message: t("licence.success"),
        });
      })
      .catch(() => {
        ElMessage({
          type: "info",
          message: t("licence.cancels"),
        });
      });
    dialogShow9.value = false;
  }

  if (commandId.value == 10) {
    ElMessageBox.confirm(
      t("licence.SubmitInverter"),
      t("licence.Tips"),
      {
        confirmButtonText: t("licence.determine"),
        cancelButtonText: t("licence.cancel"),
        type: "warning",
      }
    )
      .then(async () => {
        let data = {
          commandId: commandId.value,
          ids: ids.join(","), //逆变器id
          versionId: inverterId.value, //版本id
          remark: upgradeForm.value.remark,
          lang: lang.value,
          // stationId: powerStation.value.id,
        };
        await commandControl(data);
        ElMessage({
          type: "success",
          message: t("licence.success"),
        });
      })
      .catch(() => {
        ElMessage({
          type: "info",
          message: t("licence.cancels"),
        });
      });
    dialogShow10.value = false;
  }

  //====== 固定有功调节
  if (commandId.value == 11) {
    if (switchG.value == 1) {
      if (formInline.value.num_6 >= 0) {
        await formInlines.value?.validate();
        ElMessageBox.confirm(t("licence.Submit"), t("licence.Tips"), {
          confirmButtonText: t("licence.determine"),
          cancelButtonText: t("licence.cancel"),
          type: "warning",
        })
          .then(async () => {
            let data = {
              commandId: commandId.value,
              ids: ids.join(","),
              setVal: formInline.value.num_6,
              type: switchG.value,
              lang: lang.value,
            };
            await commandControl(data);
            if(env=='staging') {
                ElMessage({
                  type: "success",
                  duration: 40000,
                  message: t("licence.sys_restoreFactory_compare"),
                });
                setTimeout(async () => {
                  let data = {
                    stationId: powerStation.value.id,
                    commandId: 12,
                    ids: -1,
                    lang: lang.value,
                  };
                  commandControl(data);
                }, 30000);
                setTimeout(async () => {
                  let res = await getPsListByIds(ids.join(","));
                  resultList.value = res.data;
                  compareResult(9);
                }, 40000);
            }
            else{
              ElMessage({
                type: "success",
                message: t("licence.success"),
              });
            }
          })
          .catch(() => {
            ElMessage({
              type: "info",
              message: t("licence.cancels"),
            });
          });
        dialogShow11.value = false;
      } else {
        ElMessage({
          type: "error",
          message: t("licence.sys_shuzhi0"),
        });
      }
    } else {
      ElMessageBox.confirm(t("licence.Submit"), t("licence.Tips"), {
        confirmButtonText: t("licence.determine"),
        cancelButtonText: t("licence.cancel"),
        type: "warning",
      })
        .then(async () => {
          let data = {
            commandId: commandId.value,
            ids: ids.join(","),
            // setVal: formInline.value.num_6,
            type: switchG.value,
            lang: lang.value,
          };
          await commandControl(data);
          ElMessage({
            type: "success",
            message: t("licence.success"),
          });
        })
        .catch(() => {
          ElMessage({
            type: "info",
            message: t("licence.cancels"),
          });
        });
      dialogShow11.value = false;
    }
  }

  //======  安规设置
  if (commandId.value == 13) {
    if (formInline.value.num_12_0 != 123456) {
      ElMessage({
        type: "error",
        message: t("licence.pass_fail"),
      });
      return
    }
    if (
      safetyParameterData.value.country <= 32767 &&
      safetyParameterData.value.pigMinV <= 32767 &&
      safetyParameterData.value.pigMaxV <= 32767 &&
      safetyParameterData.value.pigMinF <= 32767 &&
      safetyParameterData.value.pigMaxF <= 32767 &&
      safetyParameterData.value.reconnectWait <= 32767 &&
      safetyParameterData.value.startWait <= 32767 &&
      safetyParameterData.value.riseSlope <= 32767 &&
      safetyParameterData.value.puCurveEnable <= 32767 &&
      safetyParameterData.value.puCurveStartV <= 32767 &&
      safetyParameterData.value.puCurveEndV <= 32767 &&
      safetyParameterData.value.puCurveResTime <= 32767 &&
      safetyParameterData.value.puCurveResDelay <= 32767 &&
      safetyParameterData.value.ofEnable <= 32767 &&
      safetyParameterData.value.ofPoint <= 32767 &&
      safetyParameterData.value.ofSlope <= 32767 &&
      safetyParameterData.value.ofResDelay <= 32767 &&
      safetyParameterData.value.reactiveEnable <= 32767 &&
      safetyParameterData.value.quCurveStartUv <= 32767 &&
      safetyParameterData.value.quCurveEndUv <= 32767 &&
      safetyParameterData.value.quCurveStartOv <= 32767 &&
      safetyParameterData.value.quCurveEndOv <= 32767 &&
      safetyParameterData.value.quCurveResTime <= 32767 &&
      safetyParameterData.value.quCurveResDelay <= 32767 &&
      safetyParameterData.value.fixedPowerFactorValue <= 32767 &&
      safetyParameterData.value.reactivePowerRatioValue <= 32767 &&
      safetyParameterData.value.pfCurveStartPercent <= 32767 &&
      safetyParameterData.value.pfCurveEndPercent <= 32767 &&
      safetyParameterData.value.lcEnable <= 32767 &&
      safetyParameterData.value.lcCurveVoltageOne <= 32767 &&
      safetyParameterData.value.lcCurveVoltageOneTime <= 32767 &&
      safetyParameterData.value.lcCurveVoltageTwo <= 32767 &&
      safetyParameterData.value.lcCurveVoltageTwoTime <= 32767
    ) {
      ElMessageBox.confirm(t("licence.Submit"), t("licence.Tips"), {
        confirmButtonText: t("licence.determine"),
        cancelButtonText: t("licence.cancel"),
        type: "warning",
      })
        .then(async () => {
          let data = {
            commandId: commandId.value,
            ids: ids.join(","),
            safetyParameters: safetyParameterData.value,
            lang: lang.value,
          };
          await commandControl(data);
          ElMessage({
            type: "success",
            message: t("licence.success"),
          });
        })
        .catch(() => {
          ElMessage({
            type: "info",
            message: t("licence.cancels"),
          });
        });
      dialogShow12.value = false;
      dialogShow12Check.value = false;
    } else {
      ElMessage({
        type: "error",
        message: t("licence.sys_shuzhi3"),
      });
    }
  }
}

// 逆变器弹框的tab切换
const tabShow = async (key: any) => {
  num.value = key;
  if (num.value == 1) {
    // 设备信息
    let res = await getPsInfo(inverter.value.id);
    EquipmentInfoList.value = res.data;
  } else if (num.value == 2) {
    // 故障历史
    getfaultData();
  } else {
    // 曲线图
    getCharts();
  }
}
let SingleData: any;
// 故障解决功能
const Tosolve = (item: any) => {
  TosolveShow.value = true;
  TosolveForm.value = item;
  SingleData = item;
}
// 故障解决建议确定提交
const determine = async () => {
  let query = {
    id: SingleData.id,
    realSolution: TosolveForm.value.realSolution,
  };
  let res = await getfaultSolve(query);

  TosolveShow.value = false;
  ElMessage({
    message: t("licence.sys_tijiao"),
    type: "success",
  });
  getfaultData();
}
// 逆变器历史故障
const getfaultData = async () => {
  let query = {
    id: inverter.value.id,
    pageNo: queryData.page,
    pageSize: queryData.pagesize,
    lang: lang.value,
  };
  let res = await getPsFaultHisList(query);
  faultData.value = res.data.list;
  queryData.total = res.data.total;
}
// 网关历史故障
const getGatewayFaultData = async () => {
  let query = {
    id: gatewayId.value,
    pageNo: queryDataGateway.page,
    pageSize: queryDataGateway.pagesize,
    equipmentType: 1,
    lang: lang.value,
  };
  let res = await getPsFaultHisList(query);
  gatewayFaultData.value = res.data.list;
  queryDataGateway.total = res.data.total;
}
// 网关分页
const handleSizeChangeGateway = (val: any) => {
  gatewayFaultData.value.pagesize = val;
  getGatewayFaultData();
}
const handleCurrentChangeGateway = (val: any) => {
  gatewayFaultData.value.page = val;
  getGatewayFaultData();
}
// 逆变器分页
const handleSizeChange = (val: any) => {
  queryData.pagesize = val;
  getfaultData();
}
const handleCurrentChange = (val: any) => {
  queryData.page = val;
  getfaultData();
}
// 获取逆变器曲线图
const checkInver = () => {
  if (checkedCities.value.length < 1) {
    const myChart = echarts.init(
      document.getElementById("VoltagecurveData") as HTMLElement
    ) as echarts.ECharts;
    myChart.clear();
  }
  getCharts();
}
const getCharts = async () => {
  // 获取逆变器发电趋势图
  let query = {
    lang: lang.value,
    psId: inverter.value.id,
    type: radio.value,
    searchDay: searchDay.value.stockDate,
    item: checkedCities.value.join(), //露露
    // searchDay: radio.value == 1 ? searchDay.value.stockDate : "", // 日的时候就传 searchDay.value.stockDate 否则就传 ''
  };
  let res = await getPsCharts(query);
  if (radio.value <= 1) {
    if (res.data.energyCharts) {
      getTrendcurveData(res.data.energyCharts);
    }
    if (res.data.electricityCharts) {
      let series: any[] = []; //数据
      let yAxis: any[] = []; //数据
      if(!res.data.electricityCharts.seriesList) {
            const myChart = echarts.init(document.getElementById("VoltagecurveData"));
            myChart.clear();
            let option = { title: { text: '暂无数据', x: 'center', y: 'center', textStyle: { fontSize: 16, fontWeight: 'normal', } } }
            myChart.setOption(option, true)
            return
      }
      res.data.electricityCharts?.seriesList?.forEach((item: any, index: any) => {
        let intervalY = 0;
        let xian = index; //对应标签yAxis中的第二个数据
        item.forEach((itm: any, index: any) => {
          let dataArr1 = itm.data;
          let Mid = Math.abs(Math.max(...dataArr1) / 6);
          // intervalY = Math.abs(Math.max(...dataArr1) / 6);
          if (Mid > intervalY) {
            intervalY = Mid;
          }
          series.push({
            name: itm.name,
            type: "line",
            // stack: "Total",
            symbol: "none",

            lineStyle: {
              width: 1, //设置线条粗细
            },
            emphasis: {
              focus: "series",
            },
            data: itm.data,
            yAxisIndex: xian,
          });
        });
        yAxis.push({
          type: "value",
          name: item[0].unit,
          axisTick: {
            show: false,
          },
          axisLine: {
            show: false,
          },
          axisLabel: {
            // 保留一位小数
            formatter: function (value: any) {
              return value.toFixed(1);
            },
          },
          min: 0,
          max: intervalY * 6, // 最大值
          splitNumber: 6, // 坐标轴的分割段数(预估值)
          interval: intervalY, // 强制设置坐标轴分割间隔。
        });
      });
      getVoltagecurveData(res.data.electricityCharts, series, yAxis);
    }
  } else {
    if (res.data.energyCharts) {
      getElectricityData(res.data.energyCharts);
    }
  }
}
// 获取网关曲线图
const getChartsGateway = async () => {
  // 获取逆变器发电趋势图
  let query = {
    lang: lang.value,
    gatId: gatewayId.value,
    type: radioGateway.value,
    searchDay: searchDay.value.stockDate,
    // searchDay: radio.value == 1 ? searchDay.value.stockDate : "", // 日的时候就传 searchDay.value.stockDate 否则就传 ''
  };
  let res = await getGatewayCharts(query);
  if (radioGateway.value <= 1) {
    getTrendcurveGateway(res.data);
  } else {
    getElectricityGateway(res.data);
  }
}
// 网关数据曲线图
const getTrendcurveGateway = (data: any) => {
  const myChart = echarts.init(
    document.getElementById("TrendcurveGateway") as HTMLElement
  ) as echarts.ECharts;
  let dataArr1 = data.series[0].data;
  let dataArr2 = data.series[1].data;
  let intervalY1 = Math.abs(Math.max(...dataArr1) / 6);
  let intervalY2 = Math.ceil(Math.max(...dataArr2) / 6);
  myChart.setOption({
    // 悬浮提示
    tooltip: {
      show: true,
      trigger: "axis",
      backgroundColor: "#656565",
      textStyle: { color: "#ffffff" },
      extraCssText: "box-shadow: 0px 2px 5px 0px rgba(50,107,174,0.19);",
    },
    legend: {
      itemHeight: 12,
      itemWidth: 12,
      icon: "circle",
      // data: ["累计发电量", "功率"],
    },
    // 位置
    grid: {
      left: "4%",
      right: "3%",
      // bottom: "3%",
      containLabel: true,
    },
    xAxis: {
      type: "category",
      boundaryGap: false,
      data: data.categories,
    },
    yAxis: [
      {
        type: "value",
        name: data.series[0].unit,
        axisTick: {
          show: false,
        },
        axisLine: {
          show: false,
        },
        axisLabel: {
          // 保留一位小数
          formatter: function (value: any) {
            return value.toFixed(1);
          },
        },
        min: 0,
        max: intervalY1 * 6, // 最大值
        splitNumber: 6, // 坐标轴的分割段数(预估值)
        interval: intervalY1, // 强制设置坐标轴分割间隔。
      },
      {
        type: "value",
        name: data.series[1].unit,
        axisTick: {
          show: false,
        },
        axisLine: {
          show: false,
        },
        axisLabe: {
          // 保留一位小数
          formatter: function (value: any) {
            return value.toFixed(1);
          },
        },
        min: 0,
        max: intervalY2 * 6, // 最大值
        splitNumber: 6, // 坐标轴的分割段数(预估值)
        interval: intervalY2, // 强制设置坐标轴分割间隔。
      },
    ],
    series: [
      {
        name: data.series[0].name,
        data: data.series[0].data,
        type: "line",
        symbol: "none",
        itemStyle: {
          normal: {
            color: "#5079F6",
            lineStyle: {
              width: 1, //设置线条粗细
            },
          },
        },
        areaStyle: {
          color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
            {
              offset: 0,
              color: "rgba(44,90,221)",
            },
            {
              offset: 1,
              color: "rgba(44,90,221,0)",
            },
          ]),
        },
        yAxisIndex: 0, //对应标签yAxis中的第一个数据
      },
      {
        name: data.series[1].name,
        data: data.series[1].data,
        type: "line",
        symbol: "none",
        itemStyle: {
          normal: {
            color: "#E28868",
            lineStyle: {
              width: 1, //设置线条粗细
            },
          },
        },
        areaStyle: {
          color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
            {
              offset: 0,
              color: "rgba(255,78,20)",
            },
            {
              offset: 1,
              color: "rgba(255,78,20,0)",
            },
          ]),
        },
        yAxisIndex: 1, //对应标签yAxis中的第二个数据
      },
    ],
  });
  window.addEventListener("resize", function () {
    myChart.resize();
  });
}
// 网关日以外的柱状图
const getElectricityGateway = (data: any) => {
  const myChart = echarts.init(
    document.getElementById("ElectricityGateway") as HTMLElement) as echarts.ECharts;
  myChart.setOption({
    // 悬浮提示
    tooltip: {
      show: true,
      trigger: "axis",
      backgroundColor: "#656565",
      textStyle: { color: "#ffffff" },
      extraCssText: "box-shadow: 0px 2px 5px 0px rgba(50,107,174,0.19);",
    },
    legend: { itemHeight: 12, itemWidth: 12, icon: "circle" },
    // 位置
    grid: {
      left: "4%",
      right: "3%",
      // bottom: "3%",
      containLabel: true,
    },
    xAxis: {
      type: "category",
      data: data.categories,
      boundaryGap: ["0", "1%"], //留白大小，坐标轴两边留白
    },
    yAxis: [
      {
        type: "value",
        name: data.series[0].unit,
        min: 0,
      },
    ],
    series: [
      {
        name: data.series[0].name,
        data: data.series[0].data,
        type: "bar",
        barWidth: "16",
        // barCategoryGap: "5%",
        barGap: 7,
        itemStyle: {
          color: "#5079F6",
        },
      },
    ],
  });
  window.addEventListener("resize", function () {
    myChart.resize();
  });
}

// 设备信息====弹框
const equipmentInformation = (key: any, name: any) => {
  // 弹框动态标题
  showInDialogTitle.value = name;
  // 传值索引
  equipmenttype.value = key;
  showInDialog.value = true;
  geteChartsequipment();
}
const geteChartsequipment = async () => {
  let query = {
    id: inverter.value.id,
    type: equipmenttype.value,
    lang: lang.value,
    searchDay: searchDay.value.stockDate,
  };
  let res = await getPsData(query);
  getEquipmentData(res.data);
}

// -------------------
// 数据曲线图的选择年月日
// 数据曲线图
const getTrendcurveData = (data: any) => {
  const myChart = echarts.init(document.getElementById("TrendcurveData") as HTMLElement) as echarts.ECharts;
  let dataArr1 = data.series[0].data;
  let dataArr2 = data.series[1].data;
  let intervalY1 = Math.abs(Math.max(...dataArr1) / 6);
  let intervalY2 = Math.ceil(Math.max(...dataArr2) / 6);
  myChart.setOption({
    // 悬浮提示
    tooltip: {
      show: true,
      trigger: "axis",
      backgroundColor: "#656565",
      textStyle: { color: "#ffffff" },
      extraCssText: "box-shadow: 0px 2px 5px 0px rgba(50,107,174,0.19);",
    },
    legend: {
      itemHeight: 12,
      itemWidth: 12,
      icon: "circle",
      // data: ["累计发电量", "功率"],
    },
    // 位置
    grid: {
      left: "4%",
      right: "3%",
      // bottom: "3%",
      containLabel: true,
    },
    xAxis: {
      type: "category",
      boundaryGap: false,
      data: data.categories,
    },
    yAxis: [
      {
        type: "value",
        name: data.series[0].unit,
        axisTick: {
          show: false,
        },
        axisLine: {
          show: false,
        },
        axisLabel: {
          // 保留一位小数
          formatter: function (value: any) {
            return value.toFixed(1);
          },
        },
        min: 0,
        max: intervalY1 * 6, // 最大值
        splitNumber: 6, // 坐标轴的分割段数(预估值)
        interval: intervalY1, // 强制设置坐标轴分割间隔。
      },
      {
        type: "value",
        name: data.series[1].unit,
        axisTick: {
          show: false,
        },
        axisLine: {
          show: false,
        },
        axisLabe: {
          // 保留一位小数
          formatter: function (value: any) {
            return value.toFixed(1);
          },
        },
        min: 0,
        max: intervalY2 * 6, // 最大值
        splitNumber: 6, // 坐标轴的分割段数(预估值)
        interval: intervalY2, // 强制设置坐标轴分割间隔。
      },
    ],
    series: [
      {
        name: data.series[0].name,
        data: data.series[0].data,
        type: "line",
        symbol: "none",
        itemStyle: {
          normal: {
            color: "#5079F6",
            lineStyle: {
              width: 1, //设置线条粗细
            },
          },
        },
        areaStyle: {
          color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
            {
              offset: 0,
              color: "rgba(44,90,221)",
            },
            {
              offset: 1,
              color: "rgba(44,90,221,0)",
            },
          ]),
        },
        yAxisIndex: 0, //对应标签yAxis中的第一个数据
      },
      {
        name: data.series[1].name,
        data: data.series[1].data,
        type: "line",
        symbol: "none",
        itemStyle: {
          normal: {
            color: "#E28868",
            lineStyle: {
              width: 1, //设置线条粗细
            },
          },
        },
        areaStyle: {
          color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
            {
              offset: 0,
              color: "rgba(255,78,20)",
            },
            {
              offset: 1,
              color: "rgba(255,78,20,0)",
            },
          ]),
        },
        yAxisIndex: 1, //对应标签yAxis中的第二个数据
      },
    ],
  });
  window.addEventListener("resize", function () {
    myChart.resize();
  });
}
// -------------------=============================
// 数据对比
const getVoltagecurveData = (data: any, series: any, yAxis: any) => {
  const myChart = echarts.init(document.getElementById("VoltagecurveData") as HTMLElement) as echarts.ECharts;
  myChart.clear();
  myChart.setOption(
    {
      // 悬浮提示
      tooltip: {
        show: true,
        trigger: "axis",
        backgroundColor: "#656565",
        textStyle: { color: "#ffffff" },
        extraCssText: "box-shadow: 0px 2px 5px 0px rgba(50,107,174,0.19);",
      },
      legend: {
        itemHeight: 12,
        itemWidth: 12,
        icon: "circle",
        bottom: "0%",
      },
      // 位置
      grid: {
        left: "4%",
        right: "3%",
        // bottom: "3%",
        containLabel: true,
      },
      xAxis: {
        type: "category",
        boundaryGap: false,
        data: data.categories,
      },
      yAxis: yAxis,
      series: series,
    },
    true
  );
  window.addEventListener("resize", function () {
    myChart.resize();
  });
}
// ================================
// 日以外的柱状图
const getElectricityData = (data: any) => {
  const myChart = echarts.init(document.getElementById("ElectricityData") as HTMLElement) as echarts.ECharts;
  myChart.setOption({
    // 悬浮提示
    tooltip: {
      show: true,
      trigger: "axis",
      backgroundColor: "#656565",
      textStyle: { color: "#ffffff" },
      extraCssText: "box-shadow: 0px 2px 5px 0px rgba(50,107,174,0.19);",
    },
    legend: { itemHeight: 12, itemWidth: 12, icon: "circle" },
    // 位置
    grid: {
      left: "4%",
      right: "3%",
      // bottom: "3%",
      containLabel: true,
    },
    xAxis: {
      type: "category",
      data: data.categories,
      boundaryGap: ["0", "1%"], //留白大小，坐标轴两边留白
    },
    yAxis: [
      {
        type: "value",
        name: data.series[0].unit,
        min: 0,
      },
    ],
    series: [
      {
        name: data.series[0].name,
        data: data.series[0].data,
        type: "bar",
        barWidth: "16",
        // barCategoryGap: "5%",
        barGap: 7,
        itemStyle: {
          color: "#5079F6",
        },
      },
    ],
  });
  window.addEventListener("resize", function () {
    myChart.resize();
  });
}
// ====================================
// 设备信息=====弹框
const getEquipmentData = (data: any) => {
  const myChart = echarts.init(document.getElementById("equipmentData") as HTMLElement) as echarts.ECharts;
  myChart.setOption({
    // 悬浮提示
    tooltip: {
      show: true,
      trigger: "axis",
      backgroundColor: "#656565",
      textStyle: { color: "#ffffff" },
      extraCssText: "box-shadow: 0px 2px 5px 0px rgba(50,107,174,0.19);",
    },
    legend: {
      itemHeight: 12,
      itemWidth: 12,
      icon: "circle",
      // data: ["发电量"],
    },
    // 位置
    grid: {
      left: "1.5%",
      right: "4%",
      // bottom: "3%",
      containLabel: true,
    },
    xAxis: {
      type: "category",
      boundaryGap: false,
      data: data.categories,
    },
    yAxis: {
      type: "value",
      name: data.series[0].unit,
      axisTick: {
        show: false,
      },
      axisLine: {
        show: false,
      },
    },
    series: [
      {
        name: data.series[0].unit,
        data: data.series[0].data,
        symbol: "none",
        type: "line",
        itemStyle: {
          normal: {
            color: "#5079F6",
            lineStyle: {
              width: 1, //设置线条粗细
            },
          },
        },
        areaStyle: {
          color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
            {
              offset: 0,
              color: "rgba(44,90,221)",
            },
            {
              offset: 1,
              color: "rgba(44,90,221,0)",
            },
          ]),
        },
      },
    ],
  });
  window.addEventListener("resize", function () {
    myChart.resize();
  });
}
onBeforeUnmount(() => {
  clearInterval(timer.value);
  timer.value = null;
});
</script>
<style scoped lang="scss">
// 弹框
.conten-main-b {
  margin-top: 20px;
}

.conten-main-t {
  margin-bottom: 20px;
}

.titleShow {
  display: flex;
  cursor: pointer;
  font-size: 16px;
  margin-right: 24px;
  font-weight: 600;
  margin-bottom: 30px;
  border-bottom: 1px solid #eee;
  width: 100%;
  padding-bottom: 20px;

  .titles {
    margin-right: 24px;
  }
}

::v-deep .el-dialog__header {
  padding: 0 !important;
  padding-bottom: 0;
}

::v-deep .el-dialog {
  border-radius: 6px;
}

::v-deep .el-dialog__body {
  padding: 20px;
}

// 弹框里面的表格
.tabletitle {
  margin: -20px 0 20px;
  border-left: 2px solid #305add;
  text-align: left;
  font-size: 16px;
  font-family: PingFangSC-Semibold, PingFang SC;
  font-weight: 600;
  color: #0e1319;
  padding-left: 4px;
}

td {
  border: 1px solid #d9d9d9;
  width: 200px;
  height: 50px;
  // line-height: 50px;
  padding-left: 20px;
  color: #0e1319;

  .el-icon-bottom-left {
    cursor: pointer;
    float: right;
    font-size: 20px;
    margin-right: 10px;
    color: #305add;
  }
}

// 弹框里的分页
.block {
  // display: flex;
  display: -webkit-box;
  justify-content: end;
}

.big-title {
  font-size: 16px;
  font-family: PingFangSC-Medium, PingFang SC;
  font-weight: 600;
  color: #0e1319;
  margin-bottom: 20px;
  line-height: 30px;
}

.MR2 {
  margin-right: 20px !important;
  margin-bottom: 20px;
}

// 弹框趋势图
.time-box {
  margin: -20px 0 20px 0;

  // 年月日选择
  ::v-deep .el-radio-button__inner {
    border: none;
    border-radius: 4px;
    background: #e7e7e7;
    margin-right: 10px;
  }

  ::v-deep .el-radio-button:first-child .el-radio-button__inner {
    border-radius: 4px;
  }

  ::v-deep .el-radio-button--mini .el-radio-button__inner {
    padding: 6px 12px;
  }
}

.curveData {
  height: 560px;
}

.active {
  color: #305add;
}

// 查询按钮
.el-button--primary {
  color: #ffffff;
  background-color: #305add;
  border-color: #305add;
}

.ri {
  width: 38px;
  height: 24px;
  color: #ffffff;
  background-color: #305add;
  border-radius: 2px;
  text-align: center;
  line-height: 24px;
}

.content {
  width: 100%;
  background-color: #fff;
  padding: 20px 0 0 20px;
  border-radius: 6px;
  .T-title {
    padding: 0 30px 0 0;
    font-size: 16px;
    font-family: PingFangSC-Medium, PingFang SC;
    font-weight: 600;

    .title-l {
      display: flex;
      cursor: pointer;
      flex-wrap: wrap;
      flex: 1;

      .title-l-s {
        position: relative;
        margin-right: 40px;
        font-size: 16px;
        font-weight: 600;
        // margin-top: 10px;
      }

      .hover-wangguan {
        position: absolute;
        left: -20px;
        // width: 240px;
        width: auto;
        bottom: -160px;
        z-index: 1;
        display: none;
        transition: all 0.5s;
        background: rgba(0, 0, 0, 0.8);
        box-shadow: 4px 4px 12px 0px rgba(1, 19, 47, 0.26);
        border-radius: 6px;
        color: #fff;
        padding: 15px;
        font-size: 14px;
        line-height: 28px;

        .uptriangle {
          position: absolute;
          top: -10px;
          left: 25px;
          width: 0;
          height: 0;
          border-left: 10px solid transparent;
          border-right: 10px solid transparent;
          border-bottom: 10px solid rgba(0, 0, 0, 0.8);
        }
      }

      .title-l-s:hover .hover-wangguan {
        display: block;
        // transform: ;
      }
    }

    ::v-deep .el-checkbox-button__inner {
      width: 72px;
      height: 36px;
      background: #305add;
      border-radius: 4px;
      text-align: center;
      border-color: #305add;
      color: #fff;
    }
  }

  // 设备序列号
  .inputk {
    width: 200px;
    margin-left: 20px;
    margin-right: 20px;
  }

  // 选择中后一排操作
  .i {
    font-style: normal;
    color: #305add;
    margin: 0 3px;
  }

  .buttonall {
    padding: 10px;
    background: #f0f4f9;
    color: #0e1319;
    border: none;
    margin-left: 15px;
  }

  .main {
    padding: 0;
    padding-bottom: 220px;
    display: flex;
    flex-wrap: wrap;

    .main-content {
      position: relative;
      cursor: pointer;
      margin-right: 20px;
      margin-bottom: 20px;
      width: 310px;

      //min-height: 260px;
      .titleW {
        width: 310px;
        padding: 35px 20px 20px 20px;
        background: url('../../assets/images/bg.png') no-repeat;
        background-size: cover;
        font-family: SamsungOne700;
        font-weight: 600;
        color: #fff;

        .iconBg {
          width: 13px;
          height: 13px;
          border-radius: 50%;
          background: #fff;
          position: relative;

          .iconA {
            position: absolute;
            top: -2px;
            left: -2px;
          }
        }
      }

      .tiaoHover {
        padding: 0px 20px 10px 20px;
        border: 2px solid transparent;
        border-radius: 6px;
        box-sizing: border-box;
        background-color: #f5f6f7;

        .tiao {
          display: flex;
          justify-content: space-between;
          margin-top: 8px;

          .tiao-l {
            font-size: 14px;
            font-family: PingFangSC-Regular, PingFang SC;
            // color: #666666;
          }

          .tiao-r {
            font-size: 14px;
            font-family: PingFangSC-Medium, PingFang SC;
            // font-weight: 600;
            // color: #0e1319;
          }
        }
      }
    }

    //houver 悬浮后提示
    .tiaoHover:hover {
      background: rgba(48, 90, 221, 0.11);
      border: 2px solid #305add;
      box-sizing: border-box;
    }

    .hover-content {
      position: absolute;
      left: 0;
      bottom: -260px;
      // bottom: -8px;
      left: 10px;
      z-index: 1;
      display: none;
      transition: all 0.5s;
      background: #fff;
      box-shadow: 0px 1px 12px 0px rgba(1, 19, 47, 0.26);
      border-radius: 6px;
      color: #222222;
      font-family: PingFangSC-Regular, PingFang SC;
      padding: 15px;
      font-size: 14px;
      line-height: 28px;

      .uptriangle {
        position: absolute;
        top: -10px;
        left: 25px;
        width: 0;
        height: 0;
        border-left: 10px solid transparent;
        border-right: 10px solid transparent;
        // border-bottom: 10px solid rgba(255, 255, 255, 0.8);
        border-bottom: 10px solid rgba(255, 255, 255, 1);
      }
    }

    // hover逆变器整体
    .main-content:hover .hover-content {
      display: block;
    }
  }
}

.conten-main-b {
  .head {
    background: #f5f8fa;
    height: 56px;
    line-height: 56px;
    // margin-bottom: 20px;

    li {
      font-size: 14px;
      font-family: PingFangSC-Medium, PingFang SC;
      font-weight: 600;
      color: #515a6e;
    }
  }

  ul {
    padding: 0;
    display: flex;
    height: 56px;
    line-height: 56px;

    li {
      width: 20%;
      text-align: center;
      font-size: 14px;
      font-family: PingFangSC-Regular, PingFang SC;
      font-weight: 400;
      color: #606266;

      &:nth-child(1) {
        width: 15%;
      }

      &:nth-child(2) {
        width: 50%;
      }

      &:nth-child(3) {
        width: 15%;
      }
    }
  }
}

.inputW {
  width: 93px;
  // background: #f5f7fb;
  border-radius: 4px;
}</style>
<style>.el-tooltip__popper {
  max-width: 40%;
}

.safety-right {
  display: flex;
  justify-content: flex-end
}</style>
